Skip to content

Commit

Permalink
added saving refreshtoken expires date functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
TharindaPrabhath committed Oct 1, 2021
1 parent a9bc338 commit 42fcac5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/screens/Signin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ const Signin = () => {
username: yup.string().required("Username is required"),
password: yup.string().required("Password is required"),
});
const { setAccessToken } = useTokenService();
const {
setAccessToken,
setRefreshToken,
setAccessTokenExpiresAt,
setRefreshTokenExpiresAt,
} = useTokenService();
const { setAdmin } = bindActionCreators(actionCreators, dispatch);

const formik = useFormik({
Expand All @@ -51,6 +56,9 @@ const Signin = () => {
.then((res) => {
if (res.status === 200) {
setAccessToken(res.data.accessToken);
setRefreshToken(res.data.refreshToken);
setAccessTokenExpiresAt(res.data.accessTokenExpiresAt);
setRefreshTokenExpiresAt(res.data.refreshTokenExpiresAt);
setAdmin({ username: values.username });
setSuccess(true);
} else setSuccess(false);
Expand Down

0 comments on commit 42fcac5

Please sign in to comment.