Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit b94f9f2

Browse files
author
vigneshwaranc
committed
login and signup done, successfully
1 parent cfca1c8 commit b94f9f2

File tree

5 files changed

+13
-14
lines changed

5 files changed

+13
-14
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"yup": "^0.29.1"
3232
},
3333
"scripts": {
34-
"start": "cross-env PORT=3001 react-scripts start",
34+
"start": "cross-env PORT=3505 react-scripts start",
3535
"build": "react-scripts build",
3636
"test": "react-scripts test",
3737
"eject": "react-scripts eject",

src/helpers/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const USER_INFO_LOCAL_STORAGE_KEY = 'userInfo';
1+
export const USER_INFO_LOCAL_STORAGE_KEY = 'toDoUserInfo';

src/pages/Login.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const LoginSchema = Yup.object({
1616
});
1717

1818
const initialValues = {
19-
email: 'emailw@sdl.com',
19+
email: 'todo@gmail.com',
2020
password: 'password',
2121
};
2222

src/pages/Signup.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Link, useHistory } from 'react-router-dom';
44
import { Form, Input, SubmitButton } from 'formik-antd';
55
import { Formik } from 'formik';
66
import * as Yup from 'yup';
7+
import jsSha512 from 'js-sha512';
78

89
import { API } from '../services/api.request';
910

@@ -20,17 +21,18 @@ export function Signup() {
2021
const history = useHistory();
2122

2223
const initialValues = {
23-
email: 'emailq@sdl.com',
24+
email: 'todo@gmail.com',
2425
password: 'password',
25-
firstName: 'firstName',
26-
lastName: 'lastName',
26+
firstName: 'Vigneshwaran',
27+
lastName: 'C',
2728
};
2829

2930
function handleSignup(values, { setErrors, setSubmitting }) {
31+
const { password } = values;
3032
const CREDENTIALS = {
3133
url: `/users`,
3234
method: 'post',
33-
data: values,
35+
data: { ...values, password: jsSha512(password) },
3436
setErrors,
3537
};
3638

src/services/session.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ class Session {
55
constructor() {
66
if (!isEmpty(localStorage.getItem(LOCAL_KEY))) {
77
const data = JSON.parse(localStorage.getItem(LOCAL_KEY));
8-
this.token = data.user.accessToken;
9-
this.userId = data.user._id;
10-
this.status = data.user.status;
8+
this.token = data.accessToken;
9+
this.userId = data._id;
1110
}
1211
}
1312

@@ -16,16 +15,14 @@ class Session {
1615
}
1716

1817
setToken(data) {
19-
this.token = data.user.accessToken;
20-
this.userId = data.user._id;
21-
this.status = data.user.status;
18+
this.token = data.accessToken;
19+
this.userId = data._id;
2220
localStorage.setItem(LOCAL_KEY, JSON.stringify(data));
2321
}
2422

2523
removeToken() {
2624
this.token = null;
2725
this.userId = null;
28-
this.status = null;
2926
localStorage.removeItem(LOCAL_KEY);
3027
}
3128

0 commit comments

Comments
 (0)