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