Skip to content

Commit dae0cf2

Browse files
author
FusionAuth Automation
committed
Sync from monorepo 565c3faf9fb1
1 parent d24d525 commit dae0cf2

5 files changed

Lines changed: 74 additions & 3 deletions

File tree

src/main/java/io/fusionauth/client/FusionAuthClient.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144
import io.fusionauth.domain.api.ThemeSearchRequest;
145145
import io.fusionauth.domain.api.ThemeSearchResponse;
146146
import io.fusionauth.domain.api.TwoFactorDisableRequest;
147+
import io.fusionauth.domain.api.TwoFactorUpdateRequest;
147148
import io.fusionauth.domain.api.TwoFactorRecoveryCodeResponse;
148149
import io.fusionauth.domain.api.TwoFactorRequest;
149150
import io.fusionauth.domain.api.TwoFactorResponse;
@@ -6296,6 +6297,22 @@ public ClientResponse<ThemeResponse, Errors> updateTheme(UUID themeId, ThemeRequ
62966297
.go();
62976298
}
62986299

6300+
/**
6301+
* Updates the two-factor method for the given user using a JSON body.
6302+
*
6303+
* @param userId The Id of the user to update.
6304+
* @param request The request information that contains the name and methodId along with any event information.
6305+
* @return The ClientResponse object.
6306+
*/
6307+
public ClientResponse<Void, Errors> updateTwoFactor(UUID userId, TwoFactorUpdateRequest request) {
6308+
return start(Void.TYPE, Errors.class)
6309+
.uri("/api/user/two-factor")
6310+
.urlSegment(userId)
6311+
.bodyHandler(new JSONBodyHandler(request, objectMapper()))
6312+
.put()
6313+
.go();
6314+
}
6315+
62996316
/**
63006317
* Updates the user with the given Id.
63016318
*

src/main/java/io/fusionauth/domain/Theme.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ public boolean missingTemplate() {
198198
return Stream.of(templates.accountEdit,
199199
templates.accountIndex,
200200
templates.accountTwoFactorDisable,
201+
templates.accountTwoFactorEdit,
201202
templates.accountTwoFactorEnable,
202203
templates.accountTwoFactorIndex,
203204
templates.accountWebAuthnAdd,
@@ -298,6 +299,7 @@ public static class Templates implements Buildable<Templates> {
298299
"accountEdit",
299300
"accountIndex",
300301
"accountTwoFactorDisable",
302+
"accountTwoFactorEdit",
301303
"accountTwoFactorEnable",
302304
"accountTwoFactorIndex",
303305
"accountWebAuthnAdd",
@@ -353,6 +355,8 @@ public static class Templates implements Buildable<Templates> {
353355

354356
public String accountTwoFactorDisable;
355357

358+
public String accountTwoFactorEdit;
359+
356360
public String accountTwoFactorEnable;
357361

358362
public String accountTwoFactorIndex;
@@ -454,6 +458,7 @@ public Templates(Templates other) {
454458
this.accountEdit = other.accountEdit;
455459
this.accountIndex = other.accountIndex;
456460
this.accountTwoFactorDisable = other.accountTwoFactorDisable;
461+
this.accountTwoFactorEdit = other.accountTwoFactorEdit;
457462
this.accountTwoFactorEnable = other.accountTwoFactorEnable;
458463
this.accountTwoFactorIndex = other.accountTwoFactorIndex;
459464
this.accountWebAuthnAdd = other.accountWebAuthnAdd;
@@ -515,6 +520,7 @@ public boolean equals(Object o) {
515520
return Objects.equals(accountEdit, that.accountEdit) &&
516521
Objects.equals(accountIndex, that.accountIndex) &&
517522
Objects.equals(accountTwoFactorDisable, that.accountTwoFactorDisable) &&
523+
Objects.equals(accountTwoFactorEdit, that.accountTwoFactorEdit) &&
518524
Objects.equals(accountTwoFactorEnable, that.accountTwoFactorEnable) &&
519525
Objects.equals(accountTwoFactorIndex, that.accountTwoFactorIndex) &&
520526
Objects.equals(accountWebAuthnAdd, that.accountWebAuthnAdd) &&
@@ -590,6 +596,7 @@ public int hashCode() {
590596
accountEdit,
591597
accountIndex,
592598
accountTwoFactorDisable,
599+
accountTwoFactorEdit,
593600
accountTwoFactorEnable,
594601
accountTwoFactorIndex,
595602
accountWebAuthnAdd,
@@ -644,6 +651,7 @@ public void normalize() {
644651
accountEdit = lineReturns(trimToNull(accountEdit));
645652
accountIndex = lineReturns(trimToNull(accountIndex));
646653
accountTwoFactorDisable = lineReturns(trimToNull(accountTwoFactorDisable));
654+
accountTwoFactorEdit = lineReturns(trimToNull(accountTwoFactorEdit));
647655
accountTwoFactorEnable = lineReturns(trimToNull(accountTwoFactorEnable));
648656
accountTwoFactorIndex = lineReturns(trimToNull(accountTwoFactorIndex));
649657
accountWebAuthnAdd = lineReturns(trimToNull(accountWebAuthnAdd));

src/main/java/io/fusionauth/domain/TwoFactorMethod.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021-2024, FusionAuth, All Rights Reserved
2+
* Copyright (c) 2021-2026, FusionAuth, All Rights Reserved
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,6 +35,8 @@ public class TwoFactorMethod implements Buildable<TwoFactorMethod> {
3535
*/
3636
public static final String Email = "email";
3737

38+
public static final int MaximumNameLength = 256;
39+
3840
/**
3941
* Method which authenticates using a code sent to a phone via SMS or voice.
4042
*/
@@ -54,6 +56,8 @@ public class TwoFactorMethod implements Buildable<TwoFactorMethod> {
5456

5557
public String mobilePhone;
5658

59+
public String name;
60+
5761
public String secret;
5862

5963
@JacksonConstructor
@@ -73,6 +77,7 @@ public TwoFactorMethod(TwoFactorMethod other) {
7377
this.lastUsed = other.lastUsed;
7478
this.method = other.method;
7579
this.mobilePhone = other.mobilePhone;
80+
this.name = other.name;
7681
this.secret = other.secret;
7782
}
7883

@@ -85,12 +90,12 @@ public boolean equals(Object o) {
8590
return false;
8691
}
8792
TwoFactorMethod that = (TwoFactorMethod) o;
88-
return Objects.equals(authenticator, that.authenticator) && Objects.equals(email, that.email) && Objects.equals(id, that.id) && Objects.equals(lastUsed, that.lastUsed) && Objects.equals(method, that.method) && Objects.equals(mobilePhone, that.mobilePhone) && Objects.equals(secret, that.secret);
93+
return Objects.equals(authenticator, that.authenticator) && Objects.equals(email, that.email) && Objects.equals(id, that.id) && Objects.equals(lastUsed, that.lastUsed) && Objects.equals(method, that.method) && Objects.equals(mobilePhone, that.mobilePhone) && Objects.equals(name, that.name) && Objects.equals(secret, that.secret);
8994
}
9095

9196
@Override
9297
public int hashCode() {
93-
return Objects.hash(authenticator, email, id, lastUsed, method, mobilePhone, secret);
98+
return Objects.hash(authenticator, email, id, lastUsed, method, mobilePhone, name, secret);
9499
}
95100

96101
public void normalize() {

src/main/java/io/fusionauth/domain/api/TwoFactorRequest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public class TwoFactorRequest extends BaseEventRequest implements Buildable<TwoF
3737

3838
public String mobilePhone;
3939

40+
public String name;
41+
4042
public String secret;
4143

4244
public String secretBase32Encoded;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (c) 2026, FusionAuth, All Rights Reserved
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing,
11+
* software distributed under the License is distributed on an
12+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13+
* either express or implied. See the License for the specific
14+
* language governing permissions and limitations under the License.
15+
*/
16+
package io.fusionauth.domain.api;
17+
18+
import com.inversoft.json.JacksonConstructor;
19+
import io.fusionauth.domain.Buildable;
20+
import io.fusionauth.domain.EventInfo;
21+
22+
/**
23+
* Request to update an existing two-factor method for a user.
24+
*/
25+
public class TwoFactorUpdateRequest extends BaseEventRequest implements Buildable<TwoFactorUpdateRequest> {
26+
public String methodId;
27+
28+
public String name;
29+
30+
@JacksonConstructor
31+
public TwoFactorUpdateRequest() {
32+
}
33+
34+
public TwoFactorUpdateRequest(EventInfo eventInfo, String methodId, String name) {
35+
super(eventInfo);
36+
this.methodId = methodId;
37+
this.name = name;
38+
}
39+
}

0 commit comments

Comments
 (0)