UNPKG

identity

Version:

Identity client

32 lines (21 loc) 859 B
var path = require('path'); var prompt = require('sync-prompt').prompt; module.exports = function(grunt){ //load all the other tasks from the tasks directory grunt.loadTasks(path.join(__dirname, 'tasks')); grunt.login = function(callback){ grunt.startActionhero(function(api){ var login = prompt('Username: '); var password = prompt.hidden('Password: '); api.identity.application('identity').post('login', {username:login, password:password, get_token: true}, function(err, resp){ if(resp.user && resp.access_token){ var user = api.identity.store.Model('User').new(resp.user); callback(api, resp.access_token, user); }else{ grunt.log.error('Login failed!'); return callback(api, false); } }) }); } }