fix auth error

This commit is contained in:
NCanggoro 2023-09-27 22:34:32 +07:00
parent 00c8831dc9
commit 3980f11f18

View File

@ -24,10 +24,15 @@ function Login() {
e.preventDefault(); e.preventDefault();
try { try {
const res = await loginService({ username: form.username, password: form.password }) const res = await loginService({ username: form.username, password: form.password })
if (res.error) { if (res.error.response.status == 400) {
setErrorMsg(res.error.response.data.errors) setErrorMsg(res.error.response.data.errors)
return return
} }
if(res.error) {
alert(res.error.response.data.message)
return
}
dispatch(authAdded(res.data)) dispatch(authAdded(res.data))
@ -91,6 +96,9 @@ function Login() {
</tr> </tr>
</tbody> </tbody>
</table> </table>
{errorMsg.map(x => (
<p>{x.msg}</p>
))}
<a className={'block'}>Forgout account ?</a> <a className={'block'}>Forgout account ?</a>
<input type={'submit'} value={'sign in'} className={'p-1 text-sm text-primary mt-4'} style={{ backgroundColor: '#a8adb3', borderRadius: 7 }} /> <input type={'submit'} value={'sign in'} className={'p-1 text-sm text-primary mt-4'} style={{ backgroundColor: '#a8adb3', borderRadius: 7 }} />
</form> </form>