From 0d1f1d82b7072962083ebde2005d331c867efc79 Mon Sep 17 00:00:00 2001 From: Ashelyn Dawn Date: Fri, 18 Dec 2020 18:15:16 -0700 Subject: [PATCH] Fix initial login to not show unset password --- api/auth.js | 4 +--- pages/login.js | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/api/auth.js b/api/auth.js index b6884f4..41f8575 100644 --- a/api/auth.js +++ b/api/auth.js @@ -28,9 +28,7 @@ router.post('/', parseJSON, loginValidation, async (req, res) => { await db.session.create(req, user) - const {password_hash, ...result} = user - - res.json(result) + res.json(user) }) // TODO: Login link stuff diff --git a/pages/login.js b/pages/login.js index b37439c..bb5d04f 100644 --- a/pages/login.js +++ b/pages/login.js @@ -4,13 +4,17 @@ import Head from 'next/head' import Router from 'next/router' import isEmail from 'validator/lib/isEmail' +import {useSetUser} from '~/hooks/useUser' import {FormController, Input, Button} from '~/components/form' import useAccountRedirect from '~/hooks/useAccountRedirect' export default function Login(){ useAccountRedirect() + const setUser = useSetUser() const redirectAfterLogin = user => { + setUser(user) + if (user.is_admin) Router.push('/admin') else