ember.js - Ember Auth Custom Authenticator -
ember.js - Ember Auth Custom Authenticator -
when writing custom authenticator using ember.simpleauth ember-cli, authenticate method of custom authenticator need homecoming in order found user logged in? below authenticator exists. using phalcon rest api end, seems method need nail url , authenticate user on server side, should server homecoming in order ember.simpleauth needs do?
import ember "ember"; import app '../app'; import base of operations "simple-auth/authenticators/base"; export default base.extend({ tokenendpoint: 'login', restore: function(data) { console.log('ran resotre'); }, authenticate: function(credentials) { alert(credentials.identification); alert(credentials.password); }, invalidate: function() { console.log('ran invalidate'); } });
i read ember simple auth - api
authenticate
needs homecoming promise. within method, promise needs resolved or rejected. resolved promise signal successful authentication, while rejected promise failure in authentication. here how structured quick authenticate
function.
authenticate: function (credentials, options) { homecoming new ember.rsvp.promise(function (resolve, reject) { var loginpromise = ember.$.post(<token url goes here>, { username: credentials.identification, password: credentials.password }); loginpromise.then(function (data) { resolve({ token: data.token, userdata: data.user }); }, function (error) { reject(error); }); }); }
ember.js ember-cli ember-simple-auth
Comments
Post a Comment