|
|
@ -25,13 +25,12 @@ import { login } from "./store/actions";
|
|
|
|
import { Link } from "react-router-dom";
|
|
|
|
import { Link } from "react-router-dom";
|
|
|
|
|
|
|
|
|
|
|
|
interface FormErrors {
|
|
|
|
interface FormErrors {
|
|
|
|
errorUsername?: string;
|
|
|
|
username?: string;
|
|
|
|
errorEmail?: string;
|
|
|
|
email?: string;
|
|
|
|
errorPassword?: string;
|
|
|
|
password?: string;
|
|
|
|
errorEncryptionPassword?: string;
|
|
|
|
server?: string;
|
|
|
|
errorServer?: string;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
errorGeneral?: string;
|
|
|
|
general?: string;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default function SignupPage() {
|
|
|
|
export default function SignupPage() {
|
|
|
@ -58,23 +57,23 @@ export default function SignupPage() {
|
|
|
|
const errors: FormErrors = {};
|
|
|
|
const errors: FormErrors = {};
|
|
|
|
const fieldRequired = "This field is required!";
|
|
|
|
const fieldRequired = "This field is required!";
|
|
|
|
if (!username) {
|
|
|
|
if (!username) {
|
|
|
|
errors.errorUsername = fieldRequired;
|
|
|
|
errors.username = fieldRequired;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!email) {
|
|
|
|
if (!email) {
|
|
|
|
errors.errorEmail = fieldRequired;
|
|
|
|
errors.email = fieldRequired;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!password) {
|
|
|
|
if (!password) {
|
|
|
|
errors.errorPassword = fieldRequired;
|
|
|
|
errors.password = fieldRequired;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
const passwordRulesError = enforcePasswordRules(password);
|
|
|
|
const passwordRulesError = enforcePasswordRules(password);
|
|
|
|
if (passwordRulesError) {
|
|
|
|
if (passwordRulesError) {
|
|
|
|
errors.errorPassword = passwordRulesError;
|
|
|
|
errors.password = passwordRulesError;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (process.env.NODE_ENV !== "development") {
|
|
|
|
if (process.env.NODE_ENV !== "development") {
|
|
|
|
if (showAdvanced && !server.startsWith("https://")) {
|
|
|
|
if (showAdvanced && !server.startsWith("https://")) {
|
|
|
|
errors.errorServer = "Server URI must start with https://";
|
|
|
|
errors.server = "Server URI must start with https://";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -100,20 +99,20 @@ export default function SignupPage() {
|
|
|
|
if (e.content.errors) {
|
|
|
|
if (e.content.errors) {
|
|
|
|
for (const field of e.content.errors) {
|
|
|
|
for (const field of e.content.errors) {
|
|
|
|
if (field.field === "user.username") {
|
|
|
|
if (field.field === "user.username") {
|
|
|
|
errors.errorUsername = field.detail;
|
|
|
|
errors.username = field.detail;
|
|
|
|
found = true;
|
|
|
|
found = true;
|
|
|
|
} else if (!field.field) {
|
|
|
|
} else if (!field.field) {
|
|
|
|
errors.errorGeneral = field.detail;
|
|
|
|
errors.general = field.detail;
|
|
|
|
found = true;
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!found) {
|
|
|
|
if (!found) {
|
|
|
|
errors.errorGeneral = e.content.detail ?? e.toString();
|
|
|
|
errors.general = e.content.detail ?? e.toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
errors.errorGeneral = e.toString();
|
|
|
|
errors.general = e.toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setErrors(errors);
|
|
|
|
setErrors(errors);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
@ -150,8 +149,8 @@ export default function SignupPage() {
|
|
|
|
<TextField
|
|
|
|
<TextField
|
|
|
|
type="url"
|
|
|
|
type="url"
|
|
|
|
style={styles.textField}
|
|
|
|
style={styles.textField}
|
|
|
|
error={!!errors.errorServer}
|
|
|
|
error={!!errors.server}
|
|
|
|
helperText={errors.errorServer}
|
|
|
|
helperText={errors.server}
|
|
|
|
label="Server"
|
|
|
|
label="Server"
|
|
|
|
value={server}
|
|
|
|
value={server}
|
|
|
|
onChange={handleInputChange(setServer)}
|
|
|
|
onChange={handleInputChange(setServer)}
|
|
|
@ -178,8 +177,8 @@ export default function SignupPage() {
|
|
|
|
<TextField
|
|
|
|
<TextField
|
|
|
|
type="text"
|
|
|
|
type="text"
|
|
|
|
style={styles.textField}
|
|
|
|
style={styles.textField}
|
|
|
|
error={!!errors.errorUsername}
|
|
|
|
error={!!errors.username}
|
|
|
|
helperText={errors.errorUsername}
|
|
|
|
helperText={errors.username}
|
|
|
|
label="Username"
|
|
|
|
label="Username"
|
|
|
|
value={username}
|
|
|
|
value={username}
|
|
|
|
onChange={handleInputChange(setUsername)}
|
|
|
|
onChange={handleInputChange(setUsername)}
|
|
|
@ -188,8 +187,8 @@ export default function SignupPage() {
|
|
|
|
<TextField
|
|
|
|
<TextField
|
|
|
|
type="email"
|
|
|
|
type="email"
|
|
|
|
style={styles.textField}
|
|
|
|
style={styles.textField}
|
|
|
|
error={!!errors.errorEmail}
|
|
|
|
error={!!errors.email}
|
|
|
|
helperText={errors.errorEmail}
|
|
|
|
helperText={errors.email}
|
|
|
|
label="Email"
|
|
|
|
label="Email"
|
|
|
|
value={email}
|
|
|
|
value={email}
|
|
|
|
onChange={handleInputChange(setEmail)}
|
|
|
|
onChange={handleInputChange(setEmail)}
|
|
|
@ -197,8 +196,8 @@ export default function SignupPage() {
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<PasswordField
|
|
|
|
<PasswordField
|
|
|
|
style={styles.textField}
|
|
|
|
style={styles.textField}
|
|
|
|
error={!!errors.errorPassword}
|
|
|
|
error={!!errors.password}
|
|
|
|
helperText={errors.errorPassword}
|
|
|
|
helperText={errors.password}
|
|
|
|
label="Password"
|
|
|
|
label="Password"
|
|
|
|
name="password"
|
|
|
|
name="password"
|
|
|
|
inputProps={{
|
|
|
|
inputProps={{
|
|
|
@ -221,8 +220,8 @@ export default function SignupPage() {
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
</FormGroup>
|
|
|
|
{advancedSettings}
|
|
|
|
{advancedSettings}
|
|
|
|
{errors.errorGeneral && (
|
|
|
|
{errors.general && (
|
|
|
|
<Alert severity="error" style={styles.infoAlert}>{errors.errorGeneral}</Alert>
|
|
|
|
<Alert severity="error" style={styles.infoAlert}>{errors.general}</Alert>
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
<Alert severity="warning" style={styles.infoAlert}>
|
|
|
|
<Alert severity="warning" style={styles.infoAlert}>
|
|
|
|