Skip to content
Permalink
Browse files
feat: adds option to login with password
  • Loading branch information
MantasMikal committed Feb 2, 2021
1 parent 385e2b0 commit 1137d9e98980897737bc80e14e92b79b82026dce
Show file tree
Hide file tree
Showing 6 changed files with 372 additions and 16 deletions.
@@ -1,5 +1,6 @@
import base64url from 'base64url'
import crypto from "crypto";
import bcrypt from "bcrypt";

export const randomBase64URLBuffer = (length = 32) => {
const bytes = crypto.randomBytes(length)
@@ -8,4 +9,9 @@ export const randomBase64URLBuffer = (length = 32) => {
};

export const toBase64 = (bytes) => base64url(bytes)
export const fromBase64 = (base64) => base64url.decode(base64)
export const fromBase64 = (base64) => base64url.decode(base64)

export const verifyPassword = function (user, password) {
const isMatch = bcrypt.compareSync(password, user.password);
return isMatch;
};
@@ -14,6 +14,10 @@ const User = mongoose.model(
type: String,
unique: false,
},
password: {
type: String,
unique: false,
},
lastName: {
type: String,
unique: false,

0 comments on commit 1137d9e

Please sign in to comment.