Skip to content
Snippets Groups Projects
Verified Commit 9915eb7c authored by Defendi Alberto's avatar Defendi Alberto
Browse files

Replace email with username.

parent dd6c857a
No related branches found
No related tags found
2 merge requests!56Refined auth flow and new website pages.,!42Feature/registration
......@@ -11,12 +11,12 @@ export const SignInForm: FC = () => {
const history = useHistory();
interface FormData {
email: string;
username: string;
password: string;
}
const defaultValues: FormData = {
email: '',
username: '',
password: '',
};
......@@ -29,8 +29,9 @@ export const SignInForm: FC = () => {
.post(
'/api/web/login',
{
username: values.email,
username: values.username,
password: values.password,
csrfmiddlewaretoken: sessionStorage.getItem('X-CSRFTOKEN'),
},
{
headers: {
......@@ -40,9 +41,9 @@ export const SignInForm: FC = () => {
)
.then((response) => {
if (response.data.status === 'fail') {
setError('email', {
setError('username', {
type: 'server',
message: 'Something went wrong with email',
message: 'Something went wrong with username',
});
setError('password', {
type: 'server',
......@@ -63,19 +64,17 @@ export const SignInForm: FC = () => {
data-testid="Form"
>
<InputField
name="email"
name="username"
control={control}
rules={{
validate: (value: string) =>
/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i.test(value),
required: {
value: true,
message: 'Email is not valid',
message: 'Username is not valid',
},
}}
label="Email"
error={!!errors.email}
errorMessage="Insert email"
label="username"
error={!!errors.username}
errorMessage="Insert username"
/>
<InputField
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment