mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-02-15 22:10:04 +00:00
pr feedback
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
|||||||
type UserDto struct {
|
type UserDto struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
Email *string `json:"email" `
|
Email *string `json:"email"`
|
||||||
EmailVerified bool `json:"emailVerified"`
|
EmailVerified bool `json:"emailVerified"`
|
||||||
FirstName string `json:"firstName"`
|
FirstName string `json:"firstName"`
|
||||||
LastName *string `json:"lastName"`
|
LastName *string `json:"lastName"`
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
CREATE TABLE email_verification_tokens
|
CREATE TABLE email_verification_tokens
|
||||||
(
|
(
|
||||||
id TEXT UUID KEY,
|
id UUID PRIMARY KEY,
|
||||||
created_at TIMESTAMPTZ NOT NULL,
|
created_at TIMESTAMPTZ NOT NULL,
|
||||||
token TEXT NOT NULL UNIQUE,
|
token TEXT NOT NULL UNIQUE,
|
||||||
expires_at TIMESTAMPTZ NOT NULL,
|
expires_at TIMESTAMPTZ NOT NULL,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import userStore from '$lib/stores/user-store';
|
|||||||
import type { ListRequestOptions, Paginated } from '$lib/types/list-request.type';
|
import type { ListRequestOptions, Paginated } from '$lib/types/list-request.type';
|
||||||
import type { SignupToken } from '$lib/types/signup-token.type';
|
import type { SignupToken } from '$lib/types/signup-token.type';
|
||||||
import type { UserGroup } from '$lib/types/user-group.type';
|
import type { UserGroup } from '$lib/types/user-group.type';
|
||||||
import type { User, UserCreate, UserSignUp } from '$lib/types/user.type';
|
import type { AccountUpdate, User, UserCreate, UserSignUp } from '$lib/types/user.type';
|
||||||
import { cachedProfilePicture } from '$lib/utils/cached-image-util';
|
import { cachedProfilePicture } from '$lib/utils/cached-image-util';
|
||||||
import { get } from 'svelte/store';
|
import { get } from 'svelte/store';
|
||||||
import APIService from './api-service';
|
import APIService from './api-service';
|
||||||
@@ -38,7 +38,7 @@ export default class UserService extends APIService {
|
|||||||
return res.data as User;
|
return res.data as User;
|
||||||
};
|
};
|
||||||
|
|
||||||
updateCurrent = async (user: UserCreate) => {
|
updateCurrent = async (user: AccountUpdate) => {
|
||||||
const res = await this.api.put('/users/me', user);
|
const res = await this.api.put('/users/me', user);
|
||||||
return res.data as User;
|
return res.data as User;
|
||||||
};
|
};
|
||||||
@@ -130,5 +130,5 @@ export default class UserService extends APIService {
|
|||||||
verifyEmail = async (token: string) => {
|
verifyEmail = async (token: string) => {
|
||||||
const res = await this.api.post('/users/me/verify-email', { token });
|
const res = await this.api.post('/users/me/verify-email', { token });
|
||||||
return res.data as User;
|
return res.data as User;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ export type User = {
|
|||||||
|
|
||||||
export type UserCreate = Omit<User, 'id' | 'customClaims' | 'ldapId' | 'userGroups'>;
|
export type UserCreate = Omit<User, 'id' | 'customClaims' | 'ldapId' | 'userGroups'>;
|
||||||
|
|
||||||
|
export type AccountUpdate = Omit<UserCreate, 'isAdmin' | 'disabled' | 'emailVerified'>
|
||||||
|
|
||||||
export type UserSignUp = Omit<
|
export type UserSignUp = Omit<
|
||||||
UserCreate,
|
UserCreate,
|
||||||
'isAdmin' | 'disabled' | 'displayName' | 'emailVerified'
|
'isAdmin' | 'disabled' | 'displayName' | 'emailVerified'
|
||||||
|
|||||||
@@ -31,4 +31,6 @@ export function getAuthRedirectPath(url: URL, user: User | null) {
|
|||||||
if (isAdminPath && !isAdmin) {
|
if (isAdminPath && !isAdmin) {
|
||||||
return '/settings';
|
return '/settings';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
import appConfigStore from '$lib/stores/application-configuration-store';
|
import appConfigStore from '$lib/stores/application-configuration-store';
|
||||||
import userStore from '$lib/stores/user-store';
|
import userStore from '$lib/stores/user-store';
|
||||||
import type { Passkey } from '$lib/types/passkey.type';
|
import type { Passkey } from '$lib/types/passkey.type';
|
||||||
import type { UserCreate } from '$lib/types/user.type';
|
import type { AccountUpdate, UserCreate } from '$lib/types/user.type';
|
||||||
import { axiosErrorToast, getWebauthnErrorMessage } from '$lib/utils/error-util';
|
import { axiosErrorToast, getWebauthnErrorMessage } from '$lib/utils/error-util';
|
||||||
import {
|
import {
|
||||||
KeyRound,
|
KeyRound,
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
!$appConfigStore.allowOwnAccountEdit || (!!account.ldapId && $appConfigStore.ldapEnabled)
|
!$appConfigStore.allowOwnAccountEdit || (!!account.ldapId && $appConfigStore.ldapEnabled)
|
||||||
);
|
);
|
||||||
|
|
||||||
async function updateAccount(user: UserCreate) {
|
async function updateAccount(user: AccountUpdate) {
|
||||||
let success = true;
|
let success = true;
|
||||||
await userService
|
await userService
|
||||||
.updateCurrent(user)
|
.updateCurrent(user)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
import { m } from '$lib/paraglide/messages';
|
import { m } from '$lib/paraglide/messages';
|
||||||
import UserService from '$lib/services/user-service';
|
import UserService from '$lib/services/user-service';
|
||||||
import appConfigStore from '$lib/stores/application-configuration-store';
|
import appConfigStore from '$lib/stores/application-configuration-store';
|
||||||
import type { UserCreate } from '$lib/types/user.type';
|
import type { AccountUpdate } from '$lib/types/user.type';
|
||||||
import { axiosErrorToast } from '$lib/utils/error-util';
|
import { axiosErrorToast } from '$lib/utils/error-util';
|
||||||
import { preventDefault } from '$lib/utils/event-util';
|
import { preventDefault } from '$lib/utils/event-util';
|
||||||
import { createForm } from '$lib/utils/form-util';
|
import { createForm } from '$lib/utils/form-util';
|
||||||
@@ -22,9 +22,9 @@
|
|||||||
isLdapUser = false,
|
isLdapUser = false,
|
||||||
userInfoInputDisabled = false
|
userInfoInputDisabled = false
|
||||||
}: {
|
}: {
|
||||||
account: UserCreate;
|
account: AccountUpdate;
|
||||||
userId: string;
|
userId: string;
|
||||||
callback: (user: UserCreate) => Promise<boolean>;
|
callback: (user: AccountUpdate) => Promise<boolean>;
|
||||||
isLdapUser?: boolean;
|
isLdapUser?: boolean;
|
||||||
userInfoInputDisabled?: boolean;
|
userInfoInputDisabled?: boolean;
|
||||||
} = $props();
|
} = $props();
|
||||||
@@ -39,10 +39,7 @@
|
|||||||
lastName: emptyToUndefined(z.string().max(50).optional()),
|
lastName: emptyToUndefined(z.string().max(50).optional()),
|
||||||
displayName: z.string().min(1).max(100),
|
displayName: z.string().min(1).max(100),
|
||||||
username: usernameSchema,
|
username: usernameSchema,
|
||||||
email: get(appConfigStore).requireUserEmail
|
email: get(appConfigStore).requireUserEmail ? z.email() : emptyToUndefined(z.email().optional())
|
||||||
? z.email()
|
|
||||||
: emptyToUndefined(z.email().optional()),
|
|
||||||
isAdmin: z.boolean()
|
|
||||||
});
|
});
|
||||||
type FormSchema = typeof formSchema;
|
type FormSchema = typeof formSchema;
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
lastName: existingUser?.lastName || '',
|
lastName: existingUser?.lastName || '',
|
||||||
displayName: existingUser?.displayName || '',
|
displayName: existingUser?.displayName || '',
|
||||||
email: existingUser?.email || '',
|
email: existingUser?.email || '',
|
||||||
emailVerified: existingUser?.emailVerified || emailsVerifiedPerDefault,
|
emailVerified: existingUser?.emailVerified ?? emailsVerifiedPerDefault,
|
||||||
username: existingUser?.username || '',
|
username: existingUser?.username || '',
|
||||||
isAdmin: existingUser?.isAdmin || false,
|
isAdmin: existingUser?.isAdmin || false,
|
||||||
disabled: existingUser?.disabled || false
|
disabled: existingUser?.disabled || false
|
||||||
|
|||||||
Reference in New Issue
Block a user