return username and id in login and signup page
This commit is contained in:
@@ -13,7 +13,7 @@ export type Inputs = {
|
||||
};
|
||||
|
||||
export default function Login() {
|
||||
const { setAuthorized } = useContext(AuthContext);
|
||||
const { setUser, setAuthorized } = useContext(AuthContext);
|
||||
const [message, setMessage] = useState('');
|
||||
const navigate = useNavigate();
|
||||
const [IsLoading, setIsLoading] = useState<boolean>(false);
|
||||
@@ -27,11 +27,12 @@ export default function Login() {
|
||||
.post('/api/auth/login', data, {
|
||||
withCredentials: true,
|
||||
})
|
||||
.then(() => {
|
||||
.then((res) => {
|
||||
setUser({ username: res.data.username, id: res.data.user_id });
|
||||
setAuthorized(true);
|
||||
setIsLoading(false);
|
||||
console.log('redirecting');
|
||||
navigate('/');
|
||||
navigate('/chat');
|
||||
})
|
||||
.catch((err) => {
|
||||
if (err.response) {
|
||||
|
||||
@@ -13,7 +13,8 @@ type Inputs = {
|
||||
};
|
||||
|
||||
export default function Signup() {
|
||||
const { setAuthorized } = useContext(AuthContext);
|
||||
const { setUser, setAuthorized } = useContext(AuthContext);
|
||||
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
@@ -41,10 +42,11 @@ export default function Signup() {
|
||||
.post(`/api/auth/signup`, data, {
|
||||
withCredentials: true,
|
||||
})
|
||||
.then(() => {
|
||||
.then((res) => {
|
||||
setUser({ username: res.data.username, id: res.data.user_id });
|
||||
setAuthorized(true);
|
||||
setIsLoading(false);
|
||||
navigate('/');
|
||||
navigate('/chat');
|
||||
console.log('Signed up');
|
||||
})
|
||||
.catch((err) => {
|
||||
|
||||
Reference in New Issue
Block a user