authlify-js
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -22,2 +22,3 @@ 'use strict'; | ||
var HTTPRegexp = /^http:\/\//; | ||
var storageKey = "authlify.user"; | ||
@@ -79,2 +80,18 @@ var Authlify = function () { | ||
}, { | ||
key: 'persistSession', | ||
value: function persistSession(user) { | ||
localStorage.setItem(storageKey, JSON.stringify(user)); | ||
} | ||
}, { | ||
key: 'recoverSession', | ||
value: function recoverSession() { | ||
var json = localStorage.getItem(storageKey); | ||
if (json) { | ||
var data = JSON.parse(json); | ||
return this.user(data.tokenResponse).process(data); | ||
} | ||
return null; | ||
} | ||
}, { | ||
key: 'user', | ||
@@ -101,2 +118,7 @@ value: function user(tokenResponse) { | ||
exports.default = Authlify; | ||
exports.default = Authlify; | ||
if (typeof window !== "undefined") { | ||
window.Authlify = Authlify; | ||
} |
@@ -74,12 +74,13 @@ 'use strict'; | ||
value: function reload() { | ||
var _this4 = this; | ||
return this.request('/user').then(function (response) { | ||
for (var key in response) { | ||
_this4[key] = response[key]; | ||
} | ||
return _this4; | ||
}); | ||
return this.request('/user').then(this.process.bind(this)); | ||
} | ||
}, { | ||
key: 'process', | ||
value: function process(attributes) { | ||
for (var key in attributes) { | ||
this[key] = attributes[key]; | ||
} | ||
return this; | ||
} | ||
}, { | ||
key: 'processTokenResponse', | ||
@@ -86,0 +87,0 @@ value: function processTokenResponse(tokenResponse) { |
{ | ||
"name": "authlify-js", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Authlify API client for JavaScript", | ||
@@ -8,3 +8,4 @@ "main": "lib/index.js", | ||
"compile": "babel --presets es2015 --plugins syntax-object-rest-spread,transform-object-rest-spread -d lib/ src/", | ||
"prepublish": "npm run compile" | ||
"prepublish": "npm run compile", | ||
"babelify": "browserify src/index.js -t [ babelify --presets [ es2015 ] --plugins syntax-object-rest-spread,transform-object-rest-spread ] | uglifyjs > browser/authlify.js" | ||
}, | ||
@@ -17,4 +18,6 @@ "author": "Mathias Biilmann Christensen", | ||
"babel-plugin-transform-object-rest-spread": "^6.8.0", | ||
"babel-preset-es2015": "^6.6.0" | ||
"babel-preset-es2015": "^6.6.0", | ||
"babelify": "^7.3.0", | ||
"uglify-js": "^2.6.2" | ||
} | ||
} |
@@ -27,2 +27,7 @@ # Authlify JS Client | ||
authlify.login(email, password).then( | ||
(user) => console.log("Logged in as %s", user.email), | ||
(error) => console.log("Failed to log in: %o", error); | ||
) | ||
authlify.requestPasswordRecovery(email).then( | ||
@@ -29,0 +34,0 @@ (response) => console.log("Recovery email sent"), |
Sorry, the diff of this file is not supported yet
12167
7
237
57
6