Skip to content

Commit 5cd69c2

Browse files
committed
Remove autoLogin from backend API
Keep it in the frontend CreateUser component, because we don't want admins to get logged out when they create a guest user with the modal.
1 parent f35f8d0 commit 5cd69c2

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

backend/LexBoxApi/Models/RegisterAccountInput.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ public record RegisterAccountInput([Required(AllowEmptyStrings = false)] string
77
[Required(AllowEmptyStrings = false)] string Locale,
88
[Required(AllowEmptyStrings = false)] string PasswordHash,
99
int? PasswordStrength,
10-
string TurnstileToken,
11-
bool AutoLogin = true);
10+
string TurnstileToken);

frontend/src/lib/components/Users/CreateUser.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
: endpoint === 'register' ? register
3636
: endpoint === 'createGuestUserByAdmin' ? createGuestUserByAdmin
3737
: () => { throw new Error(`CreateUser doesn't know how to handle endpoint type ${endpoint}`) };
38-
const { user, error } = await endpointHandler($form.password, $form.score, $form.name, $form.email, $form.locale, turnstileToken, autoLogin);
38+
const { user, error } = await endpointHandler($form.password, $form.score, $form.name, $form.email, $form.locale, turnstileToken);
3939
if (error) {
4040
if (error.turnstile) {
4141
$message = $t('turnstile.invalid');

frontend/src/lib/user.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export async function login(userId: string, password: string): Promise<LoginResu
8484
}
8585

8686
type RegisterResponse = { error?: { turnstile: boolean, accountExists: boolean, invalidInput: boolean }, user?: LexAuthUser };
87-
export async function createUser(endpoint: string, password: string, passwordStrength: number, name: string, email: string, locale: string, turnstileToken: string, autoLogin: boolean): Promise<RegisterResponse> {
87+
export async function createUser(endpoint: string, password: string, passwordStrength: number, name: string, email: string, locale: string, turnstileToken: string): Promise<RegisterResponse> {
8888
const response = await fetch(endpoint, {
8989
method: 'post',
9090
headers: {
@@ -96,7 +96,6 @@ export async function createUser(endpoint: string, password: string, passwordStr
9696
locale,
9797
turnstileToken,
9898
passwordStrength,
99-
autoLogin,
10099
passwordHash: await hash(password),
101100
})
102101
});
@@ -111,13 +110,13 @@ export async function createUser(endpoint: string, password: string, passwordStr
111110
const userJson: LexAuthUser = jwtToUser(responseJson);
112111
return { user: userJson };
113112
}
114-
export function register(password: string, passwordStrength: number, name: string, email: string, locale: string, turnstileToken: string, autoLogin: boolean): Promise<RegisterResponse> {
115-
return createUser('/api/User/registerAccount', password, passwordStrength, name, email, locale, turnstileToken, autoLogin);
113+
export function register(password: string, passwordStrength: number, name: string, email: string, locale: string, turnstileToken: string): Promise<RegisterResponse> {
114+
return createUser('/api/User/registerAccount', password, passwordStrength, name, email, locale, turnstileToken);
116115
}
117-
export function acceptInvitation(password: string, passwordStrength: number, name: string, email: string, locale: string, turnstileToken: string, autoLogin: boolean): Promise<RegisterResponse> {
118-
return createUser('/api/User/acceptInvitation', password, passwordStrength, name, email, locale, turnstileToken, autoLogin);
116+
export function acceptInvitation(password: string, passwordStrength: number, name: string, email: string, locale: string, turnstileToken: string): Promise<RegisterResponse> {
117+
return createUser('/api/User/acceptInvitation', password, passwordStrength, name, email, locale, turnstileToken);
119118
}
120-
export async function createGuestUserByAdmin(password: string, passwordStrength: number, name: string, email: string, locale: string, _turnstileToken: string, _autoLogin: boolean): Promise<RegisterResponse> {
119+
export async function createGuestUserByAdmin(password: string, passwordStrength: number, name: string, email: string, locale: string, _turnstileToken: string): Promise<RegisterResponse> {
121120
const passwordHash = await hash(password);
122121
const gqlInput: CreateGuestUserByAdminInput = {
123122
passwordHash,

0 commit comments

Comments
 (0)