Skip to content

Commit

Permalink
debugging session logout
Browse files Browse the repository at this point in the history
  • Loading branch information
AvinashMudunuri committed Aug 21, 2024
1 parent 006016e commit 82328c1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion controllers/userController.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ class UserController {

async logout(req, res) {
try {
console.log(`Triggered Logout`)
const token = req.header('Authorization').replace('Bearer ', '');
const response = await sessionService.deleteSession(token);
if (repsonse) {
if (response) {
res.status(200).json({
message: 'Logout Successful',
});
Expand Down
1 change: 1 addition & 0 deletions domain/repositories/sessionRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class SessionRepository {
return await session.save();
}
async deleteSession(token) {
console.log(`Session Repository delete`)
return await Session.findOneAndDelete({ token });
}
async findByToken(token) {
Expand Down
2 changes: 2 additions & 0 deletions domain/services/sessionService.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ class SessionService {
return await sessionRepository.createSession(data);
}
async deleteSession(token) {
console.log(`Session Service delete: `, token )
const session = await sessionRepository.deleteSession(token);
if (session) {
console.log(`Session Service delete success: `, session )
return session
} else {
throw new Error('Session with this token doesnot exists');
Expand Down

0 comments on commit 82328c1

Please sign in to comment.