Skip to content

Commit

Permalink
🌱 Add support to use rememberDevice param in polling and verify. (#111)
Browse files Browse the repository at this point in the history
Similar to autoPush, we now support rememberDevice function that will be evaluated before making the request.

Resolves: OKTA-158993
  • Loading branch information
alexeystadnikov-okta authored and mauriciocastillosilva-okta committed Apr 26, 2018
1 parent 2e772ee commit f872b34
Show file tree
Hide file tree
Showing 3 changed files with 451 additions and 15 deletions.
28 changes: 23 additions & 5 deletions lib/tx.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,18 @@ function getPollFn(sdk, res, ref) {
else if (autoPush !== undefined && autoPush !== null) {
opts.autoPush = !!autoPush;
}
if (rememberDevice) {
opts.rememberDevice = true;
if (typeof rememberDevice === 'function') {
try {
opts.rememberDevice = !!rememberDevice();
}
catch (e) {
return Q.reject(new AuthSdkError('RememberDevice resulted in an error.'));
}
}
else if (rememberDevice !== undefined && rememberDevice !== null) {
opts.rememberDevice = !!rememberDevice;
}

var href = pollLink.href + util.toQueryParams(opts);
return http.post(sdk, href, getStateToken(res), {
saveAuthnState: false
Expand Down Expand Up @@ -210,9 +219,18 @@ function link2fn(sdk, res, obj, link, ref) {
data = util.omit(data, 'autoPush');
}

if (data.rememberDevice !== undefined) {
if (data.rememberDevice) {
params.rememberDevice = true;
var rememberDevice = data.rememberDevice;
if (rememberDevice !== undefined) {
if (typeof rememberDevice === 'function') {
try {
params.rememberDevice = !!rememberDevice();
}
catch (e) {
return Q.reject(new AuthSdkError('RememberDevice resulted in an error.'));
}
}
else if (rememberDevice !== null) {
params.rememberDevice = !!rememberDevice;
}
data = util.omit(data, 'rememberDevice');

Expand Down
Loading

0 comments on commit f872b34

Please sign in to comment.