Save JWT to user on login
This commit is contained in:
1 parent
62ce8e33b6
commit
5b2a05bc79
2 files changed
+5
No files matched your search
@@ -142,6 +142,8 @@ const loginController = async (req, res, next) => {
|
||||
|
||||
// Happy path, return token
|
||||
const token = issueToken(userWithoutPassword);
|
||||
user.authToken = token;
|
||||
await user.save();
|
||||
// reset avatar image
|
||||
userWithoutPassword.avatarImage = user.avatarImage;
|
||||
|
||||
|
||||
@@ -40,6 +40,9 @@ const UserSchema = mongoose.Schema(
|
||||
default: "user",
|
||||
enum: ["user", "admin"],
|
||||
},
|
||||
authToken: {
|
||||
type: String,
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
|
||||
Reference in new issue
Block a user