Skip to content

Commit

Permalink
v0.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
davidep87 committed Sep 28, 2017
1 parent 2f4b961 commit 5cb4b4f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "secure-jws-session",
"version": "0.2.3",
"version": "0.2.4",
"description": "Secure json web signature sessions with Redis",
"main": "index.js",
"scripts": {
Expand Down
14 changes: 1 addition & 13 deletions src/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class Session {
* @param {unixtime} session.exp expiration time of token
*/
async insert(session){
console.log('INSERT SESSION', session)
await client.set(`${session.type}-${session.user}`, `${session.token}`, 'EX', session.exp)
}

Expand All @@ -49,22 +48,13 @@ class Session {

const decoded = await this.decodeToken(token)

console.log('DECODED', decoded)

if(!decoded){

message = TOKEN_NOT_VALID

} else {

let nowDate = new Date()
let decodedDate = new Date(decoded.exp)

console.log('DECODED EXP', decoded.exp)
console.log('DECODED EXP DATE', decodedDate)
console.log('DATE', nowDate)

if(nowDate > decodedDate){
if(new Date() > new Date(decoded.exp)){

await client.del(`${decoded.type}-${decoded.id}`)
message = TOKEN_NOT_VALID
Expand All @@ -73,8 +63,6 @@ class Session {

const storedToken = await this.retrieveKey(`${decoded.type}-${decoded.id}`)

console.log('STORED TOKEN', storedToken)

if(storedToken === token)
isLogged = true

Expand Down

0 comments on commit 5cb4b4f

Please sign in to comment.