Skip to content
This repository was archived by the owner on Feb 18, 2025. It is now read-only.

Add support for POST method #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions lib/strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ PasswordlessStrategy.prototype.authenticate = function(req, options) {
}

//get request parameters to check the authentication state
var user = this.getParam(req.query, this.options.userField, 'user');
var token = this.getParam(req.query, this.options.tokenField, 'token');
var uid = this.getParam(req.query, this.options.uidField, 'uid');
var user = this.getParam(req, this.options.userField, 'user');
var token = this.getParam(req, this.options.tokenField, 'token');
var uid = this.getParam(req, this.options.uidField, 'uid');

//if a token and a uid was specified, verify the token
//if only a user was specified, generate a token and send it
Expand All @@ -124,8 +124,11 @@ PasswordlessStrategy.prototype.authenticate = function(req, options) {
};

//Get a parameter value from an object.
PasswordlessStrategy.prototype.getParam = function(obj, field, defaultField) {
return obj[field || defaultField];
PasswordlessStrategy.prototype.getParam = function(req, field, defaultField) {
var key = field || defaultField
if (req.body && req.body[key])
return req.body[key];
return req.query[key];
};

//Use the specified delivery to genrate and send a token.
Expand Down