Skip to content

Commit

Permalink
Fixed username passing when logging in with Google
Browse files Browse the repository at this point in the history
`login_username` is not set in Cookies when logging in with Google. This fixes that by passing the username from the backend to the frontend.
  • Loading branch information
chrsrns committed Oct 18, 2023
1 parent 8d4cdab commit 74443ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions routes/auth.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ router.post('/login', async (req, res, next) => {
accessToken,
refreshToken,
type: existingUser.type,
id: existingUser.id
id: existingUser.id,
login_username: existingUser.login_username
});
} catch (err) {

Expand Down Expand Up @@ -278,7 +279,8 @@ router.post('/googlelogin', async (req, res, next) => {
accessToken,
refreshToken,
type: existingUser.type,
id: existingUser.id
id: existingUser.id,
login_username: existingUser.login_username
});
} catch (err) {
console.error(err)
Expand Down
4 changes: 2 additions & 2 deletions src-frontend-react/src/components/LoginFormModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const LoginFormModal = ({ show, onHide, isLoggingIn }) => {
if (response.ok)
return response.json(); else throw response;
}).then((data) => {
setCookie("login_username", username)
setCookie("login_username", data.login_username)
setCookie("accessToken", data.accessToken)
setCookie("refreshToken", data.refreshToken)
setCookie("usertype", data.type)
Expand All @@ -59,7 +59,7 @@ export const LoginFormModal = ({ show, onHide, isLoggingIn }) => {
if (response.ok)
return response.json(); else throw response;
}).then((data) => {
setCookie("login_username", username)
setCookie("login_username", data.login_username)
setCookie("accessToken", data.accessToken)
setCookie("refreshToken", data.refreshToken)
setCookie("usertype", data.type)
Expand Down

0 comments on commit 74443ed

Please sign in to comment.