Skip to content

Commit

Permalink
[api] Added new user action: 'whoami`
Browse files Browse the repository at this point in the history
  • Loading branch information
Marak committed Sep 2, 2011
1 parent 1b6c39c commit 87bae65
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/jitsu.js
Expand Up @@ -56,6 +56,7 @@ jitsu.commands.alias('conf', { resource: 'config', command: 'list' });
jitsu.commands.alias('login', { resource: 'users', command: 'login' });
jitsu.commands.alias('logout', { resource: 'users', command: 'logout' });
jitsu.commands.alias('signup', { resource: 'users', command: 'create' });
jitsu.commands.alias('whoami', { resource: 'users', command: 'whoami' });

var eyes = require('eyes'),
winston = require('winston'),
Expand All @@ -75,6 +76,9 @@ require('pkginfo')(module, 'version');
jitsu.start = function (argv, callback) {
var command = argv._;

//
// Special -v command for showing current version without winston formatting
//
if (argv.version || argv.v) {
console.log('v' + jitsu.version);
process.exit(0);
Expand Down
11 changes: 11 additions & 0 deletions lib/jitsu/commands/users.js
Expand Up @@ -20,6 +20,7 @@ users.usage = [
'jitsu users forgot <username> [<shake>]',
'jitsu users logout',
'jitsu users changepassword',
'jitsu users whoami',
'',
'You will be prompted for additional user information',
'as required.'
Expand Down Expand Up @@ -298,6 +299,16 @@ users.login.usage = [
'jitsu login'
];

//
// ### function whoami (callback)
// #### @callback {function} Continuation to pass control to when complete.
// Retrieves the name of the current logged in user
//
users.whoami = function (callback) {
var username = jitsu.config.get('username') || 'not logged in'
winston.info('You are: ' + username.magenta);
};

function forgotResetHelper (username, shake, callback) {
jitsu.config.set('username', username);
jitsu.config.set('password', shake);
Expand Down

0 comments on commit 87bae65

Please sign in to comment.