mirror of
https://github.com/idanoo/autobrr
synced 2025-07-24 01:09:13 +00:00
feat(auth): change password and username (#1295)
* feat(backend): added change password api endpoint. * feat(web): added profile UI to change password. I think we can change the username too, but I don't know if we should for now disabled the username field. * refactor: don't leak username or password. * refactor: protect the route. * generic * feat: add ChangeUsername * fix(tests): speculative fix for TestUserRepo_Update * Revert "feat: add ChangeUsername" This reverts commit d4c1645002883a278aa45dec3c8c19fa1cc75d9b. * refactor into 1 endpoint that handles both * feat: added option to change username as well. :pain: * refactor: frontend * refactor: function names in backend I think this makes it more clear what their function is * fix: change to 2 cols with separator * refactor: update user * fix: test db create user --------- Co-authored-by: Kyle Sanderson <kyle.leet@gmail.com> Co-authored-by: soup <soup@r4tio.dev> Co-authored-by: martylukyy <35452459+martylukyy@users.noreply.github.com> Co-authored-by: ze0s <ze0s@riseup.net>
This commit is contained in:
parent
d898b3cd8d
commit
df2612602b
17 changed files with 390 additions and 57 deletions
|
@ -79,6 +79,7 @@ export const TextField = ({
|
|||
)}
|
||||
disabled={disabled}
|
||||
placeholder={placeholder}
|
||||
data-1p-ignore
|
||||
/>
|
||||
|
||||
{meta.touched && meta.error && (
|
||||
|
@ -116,42 +117,42 @@ export const RegexField = ({
|
|||
disabled
|
||||
}: RegexFieldProps) => {
|
||||
const validRegex = (pattern: string) => {
|
||||
|
||||
|
||||
// Check for unsupported lookahead and lookbehind assertions
|
||||
if (/\(\?<=|\(\?<!|\(\?=|\(\?!/.test(pattern)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Check for unsupported atomic groups
|
||||
if (/\(\?>/.test(pattern)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Check for unsupported recursive patterns
|
||||
if (/\(\?(R|0)\)/.test(pattern)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Check for unsupported possessive quantifiers
|
||||
if (/[*+?]{1}\+|\{[0-9]+,[0-9]*\}\+/.test(pattern)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Check for unsupported control verbs
|
||||
if (/\\g</.test(pattern)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Check for unsupported conditionals
|
||||
if (/\(\?\((\?[=!][^)]*)\)[^)]*\|?[^)]*\)/.test(pattern)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Check for unsupported backreferences
|
||||
if (/\\k</.test(pattern)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Check if the pattern is a valid regex
|
||||
try {
|
||||
new RegExp(pattern);
|
||||
|
@ -160,7 +161,7 @@ export const RegexField = ({
|
|||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
const validateRegexp = (val: string) => {
|
||||
let error = "";
|
||||
|
@ -548,6 +549,7 @@ interface PasswordFieldProps {
|
|||
defaultValue?: string;
|
||||
help?: string;
|
||||
required?: boolean;
|
||||
tooltip?: JSX.Element;
|
||||
}
|
||||
|
||||
export const PasswordField = ({
|
||||
|
@ -558,6 +560,7 @@ export const PasswordField = ({
|
|||
columns,
|
||||
autoComplete,
|
||||
help,
|
||||
tooltip,
|
||||
required
|
||||
}: PasswordFieldProps) => {
|
||||
const [isVisible, toggleVisibility] = useToggle(false);
|
||||
|
@ -570,8 +573,13 @@ export const PasswordField = ({
|
|||
)}
|
||||
>
|
||||
{label && (
|
||||
<label htmlFor={name} className="block ml-px text-xs font-bold text-gray-800 dark:text-gray-100 uppercase tracking-wide">
|
||||
{label} {required && <span className="text-gray-500">*</span>}
|
||||
<label htmlFor={name} className="flex ml-px text-xs font-bold text-gray-800 dark:text-gray-100 uppercase tracking-wide">
|
||||
{tooltip ? (
|
||||
<DocsTooltip label={label}>{tooltip}</DocsTooltip>
|
||||
) : (
|
||||
label
|
||||
)}
|
||||
{required && <span className="text-red-500">*</span>}
|
||||
</label>
|
||||
)}
|
||||
<div>
|
||||
|
@ -591,7 +599,7 @@ export const PasswordField = ({
|
|||
meta.touched && meta.error
|
||||
? "border-red-500 focus:ring-red-500 focus:border-red-500"
|
||||
: "border-gray-300 dark:border-gray-700 focus:ring-blue-500 dark:focus:ring-blue-500 focus:border-blue-500 dark:focus:border-blue-500",
|
||||
"mt-1 block w-full rounded-md bg-gray-100 dark:bg-gray-850 dark:text-gray-100"
|
||||
"mt-1 block w-full rounded-md bg-gray-100 dark:bg-gray-815 dark:text-gray-100"
|
||||
)}
|
||||
placeholder={placeholder}
|
||||
/>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue