wrapup
This commit is contained in:
@@ -24,8 +24,8 @@ export const attemptLogin = async (data: IUserAuth) => {
|
||||
}
|
||||
|
||||
export const attemptLogout = async () => {
|
||||
const response = await fetch(API + 'auth').then(response => response.json());
|
||||
return response;
|
||||
const result = await fetch(API + 'auth/logout', { method: "DELETE" }).then(response => response.json());
|
||||
return result;
|
||||
}
|
||||
|
||||
export const attemptRegister = async (data: IUser) => {
|
||||
|
||||
@@ -56,10 +56,6 @@ export default class AuthService {
|
||||
}
|
||||
}
|
||||
|
||||
async logout() {
|
||||
|
||||
}
|
||||
|
||||
// methods for Google OAuth
|
||||
async googleRegister() {
|
||||
|
||||
|
||||
@@ -39,14 +39,17 @@ export const authRoute = (app: Express, passport: PassportStatic) => {
|
||||
}
|
||||
})
|
||||
|
||||
router.post('/logout', passport.authenticate('local', async (req, res, next) => {
|
||||
router.delete('/logout', async (req, res, next) => {
|
||||
try {
|
||||
if (req.session) req.session.destroy();
|
||||
res.sendStatus(200);
|
||||
req.session.destroy((err) => {
|
||||
if (err) throw err;
|
||||
})
|
||||
res.clearCookie('userid');
|
||||
res.status(204).send({ success: true });
|
||||
} catch(e) {
|
||||
next(e);
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
router.post('/register', async (req, res, next) => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user