These are chat archives for ecjs/Concierge

19th
Nov 2014
Mark Harrell
@ecjs
Nov 19 2014 01:00
Hey Joe when you get a chance, go ahead and throw me a pull request so we can try and get even
Joe Elsey
@joeelsey
Nov 19 2014 01:06
ok.
sent
Joe Elsey
@joeelsey
Nov 19 2014 01:50
Just a heads up. The GET for a confirmed concierge isn't working. Either returns an empty array or nothing if you put the res.body.name option that is currently in there.
Mark Harrell
@ecjs
Nov 19 2014 02:10
let me take a look
hey joe, your mocha tests dont seem to be running
Joe Elsey
@joeelsey
Nov 19 2014 02:10
I just started the change test
Mark Harrell
@ecjs
Nov 19 2014 02:10
oh ok
Joe Elsey
@joeelsey
Nov 19 2014 02:10
So its broken
Mark Harrell
@ecjs
Nov 19 2014 02:11
np
ill let you take care of all of that
Joe Elsey
@joeelsey
Nov 19 2014 02:11
build fail
lol
Mark Harrell
@ecjs
Nov 19 2014 02:11
I will take a look at the confirmed concierge
Joe Elsey
@joeelsey
Nov 19 2014 02:11
Every other test works. I also forgot about the concierge test
If you want to check you can run mocha on each individual test
Mark Harrell
@ecjs
Nov 19 2014 02:11
yah that get request for concierge
Joe Elsey
@joeelsey
Nov 19 2014 02:11
All should pass except for the change test
Mark Harrell
@ecjs
Nov 19 2014 02:11
need to fix that
no biggie..you got it
Chareesa Graham
@Chareesa
Nov 19 2014 02:12
goooooOOOOO TEAM!
Joe Elsey
@joeelsey
Nov 19 2014 02:12
I made it pass by just requiring an object
Mark Harrell
@ecjs
Nov 19 2014 02:12
haha! we have a lot of code guys
I like it
Joe Elsey
@joeelsey
Nov 19 2014 02:12
But I'm guessing it should actually return a user or even a jwt
I might leave a little earlier tonight. Like between 7 or 8
Mark Harrell
@ecjs
Nov 19 2014 02:12
ok
Joe Elsey
@joeelsey
Nov 19 2014 02:12
I know. I'm lazy
Mark Harrell
@ecjs
Nov 19 2014 02:12
chareesa, do you have a specific file you have been working on
Joe Elsey
@joeelsey
Nov 19 2014 02:12
:)
Mark Harrell
@ecjs
Nov 19 2014 02:13
or feature..just incase I should avoid a file
I might work on this concierge
as well as getting all of the concierge’s jobs
Chareesa Graham
@Chareesa
Nov 19 2014 02:13
I just sat down at home. I'm gonna pick up the reset password email thing
Mark Harrell
@ecjs
Nov 19 2014 02:14
ok..
can I make a recommendation?
Chareesa Graham
@Chareesa
Nov 19 2014 02:14
eya
yea
Mark Harrell
@ecjs
Nov 19 2014 02:15
let me find the solution I was looking at
Chareesa Graham
@Chareesa
Nov 19 2014 02:15
lol
Mark Harrell
@ecjs
Nov 19 2014 02:16
this is my rec:
sendgrid has great email delivery
Chareesa Graham
@Chareesa
Nov 19 2014 02:17
yep
that's part of this solution I'm looking at
Mark Harrell
@ecjs
Nov 19 2014 02:17
the free package is 200 emails a day
Chareesa Graham
@Chareesa
Nov 19 2014 02:17
it intermixes nodemailer with sengrid
Mark Harrell
@ecjs
Nov 19 2014 02:17
well it doesnt look like you need nodemailer
Chareesa Graham
@Chareesa
Nov 19 2014 02:17
hmm
Mark Harrell
@ecjs
Nov 19 2014 02:17
you can just use that npm package
its a lot like twilio
var sendgrid  = require('sendgrid')(api_user, api_key);
sendgrid.send({
  to:       'example@example.com',
  from:     'other@example.com',
  subject:  'Hello World',
  text:     'My first email through SendGrid.'
}, function(err, json) {
  if (err) { return console.error(err); }
  console.log(json);
});
thats all you need
This npm package is well supported too
Chareesa Graham
@Chareesa
Nov 19 2014 02:22
alright I'll try this in a new file
Mark Harrell
@ecjs
Nov 19 2014 02:26
you need a sendgrid trial account
Chareesa Graham
@Chareesa
Nov 19 2014 02:29
I got one while at Code Fellows :)
not sure how long it takes before I can send emails..
Mark Harrell
@ecjs
Nov 19 2014 02:30
nice!
should be right away..
pretty sure
Chareesa Graham
@Chareesa
Nov 19 2014 02:30
"Your account is still being provisioned. You will not be able to send out any email."
Mark Harrell
@ecjs
Nov 19 2014 02:30
o
lol
Joe Elsey
@joeelsey
Nov 19 2014 02:31
change username passes tests
change phone and change password do not
Chareesa Graham
@Chareesa
Nov 19 2014 02:32
noooo
it worked for ME!
rofl
Mark Harrell
@ecjs
Nov 19 2014 02:32
do we blame the tester or the coder
:)
Joe Elsey
@joeelsey
Nov 19 2014 02:32
uh oh
So I'm setting a header with the jwt
Let me try something
password works now
Mark Harrell
@ecjs
Nov 19 2014 02:36
nailed it
Chareesa Graham
@Chareesa
Nov 19 2014 02:36
yesss
Joe Elsey
@joeelsey
Nov 19 2014 02:37
so
is there a difference betwen passwordReset and changePassword?
I think that's where I was confused
They seem to be similar
Mark Harrell
@ecjs
Nov 19 2014 02:37
password reset actually creates a random password
Chareesa Graham
@Chareesa
Nov 19 2014 02:37
yep!
Mark Harrell
@ecjs
Nov 19 2014 02:37
change password lets the user specify
Joe Elsey
@joeelsey
Nov 19 2014 02:38
password reset
works. change password does not
Mark Harrell
@ecjs
Nov 19 2014 02:38
password reset doesnt need a test yet
Chareesa Graham
@Chareesa
Nov 19 2014 02:38
yea.. I'm working on that now
Mark Harrell
@ecjs
Nov 19 2014 02:38
basically, we are going to send an email
with their password
Chareesa Graham
@Chareesa
Nov 19 2014 02:38
It WORKS... but yea..
Joe Elsey
@joeelsey
Nov 19 2014 02:38
Well. it should probably have a test?
Chareesa Graham
@Chareesa
Nov 19 2014 02:39
dunno how to test that yet..
Mark Harrell
@ecjs
Nov 19 2014 02:39
well.. we wont be able to test
if the user received the email
we can just make sure that it actually successfully sends it
Joe Elsey
@joeelsey
Nov 19 2014 02:39
but we can test for the tempPass
Chareesa Graham
@Chareesa
Nov 19 2014 02:40
If you need Joe.. here's the tutorial I'm looking at: http://sahatyalkabov.com/how-to-implement-password-reset-in-nodejs/
It's almost to the bottom of that article
Joe Elsey
@joeelsey
Nov 19 2014 02:40
test for phone number doesn't work yet.
I set the header and send he _id, but I get a timeout
change phone that is
Mark Harrell
@ecjs
Nov 19 2014 02:41
Chareesa, I dont think we want to implement this complicated of a change password..
basically, we just want to randomize their password, and send it to their email for now
Joe Elsey
@joeelsey
Nov 19 2014 02:42
Why is change phone a post instead of a put?
Chareesa Graham
@Chareesa
Nov 19 2014 02:43
hm, good question.
oh, what? I don't see it in mine
Joe Elsey
@joeelsey
Nov 19 2014 02:43
might be the reason its failing for me
change phone js
Chareesa Graham
@Chareesa
Nov 19 2014 02:44
oh.. cause I'm in my local master
urgh
Joe Elsey
@joeelsey
Nov 19 2014 02:45
woop woop! code police coming through
Chareesa Graham
@Chareesa
Nov 19 2014 02:45
haha
Joe Elsey
@joeelsey
Nov 19 2014 02:45
step out of the master
Chareesa Graham
@Chareesa
Nov 19 2014 02:45
trying to
Mark Harrell
@ecjs
Nov 19 2014 02:46
ok…here is some code for the forgot password Chareesa
```
'use strict';

var User = require('../models/user_model');
var sendgrid = require('sendgrid');

module.exports = function(app, jwtauth) {
  var generatePassword = function() {
    var length = 8;
    var charset = 'abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
    var retVal = '';
    for (var i = 0, n = charset.length; i < length; ++i) {
      retVal += charset.charAt(Math.floor(Math.random() * n));
    }
    return retVal;
  };
  app.get('/passwordReset', jwtauth, function(req, res) {
    User.findOne({username: req.user.username}, function(err, user) {
      if (err) return res.status(500).send('there was an error' + err);
      user.password = generatePassword();
      user.save(function(err) {
        if (err) return res.status(500).send('there was an error' + err);
      });
      sendgrid.send({
        to:       user.username,
        from:     'support@conciergeapp.co',
        subject:  'Password Reset for Concierge',
        text:     'Here is your new password for Concierge: ' + user.password
        }, function(err, json) {
            if (err) { return console.error(err); }
            console.log(json);
          });
    });
  });
};
take a look, just reformated your code to include an email from sendgrid
this should work just fine
Joe Elsey
@joeelsey
Nov 19 2014 02:49
yeah. currently the way the change phone route is written there is a time out if its either a PUT or a POST.
I think its because the userfindone has trouble with find by id
Maybe consider username since that has been working so far?
Chareesa Graham
@Chareesa
Nov 19 2014 02:50
sighs with relief ahhh I'm merged with the stream.
And thanks Mark. I'll test this out.
Mark Harrell
@ecjs
Nov 19 2014 02:52
np
once sendgrid allows it
:)
Chareesa Graham
@Chareesa
Nov 19 2014 02:52
oh.. right.
tomorrow I'll test this out.
Mark Harrell
@ecjs
Nov 19 2014 02:53
k
Chareesa Graham
@Chareesa
Nov 19 2014 02:53
Is that a real email? support@ concierge?
Mark Harrell
@ecjs
Nov 19 2014 02:53
not yet ;)
will be soon
I am working on that now
Chareesa Graham
@Chareesa
Nov 19 2014 02:54
ha!
Mark Harrell
@ecjs
Nov 19 2014 02:54
Chareesa Graham
@Chareesa
Nov 19 2014 02:54
OOoooo
Mark Harrell
@ecjs
Nov 19 2014 02:54
:P
personally, I am waiting till we launch secretconciergeapp.co
Chareesa Graham
@Chareesa
Nov 19 2014 02:54
rofl!
mark@secretconcierge.co
Mark Harrell
@ecjs
Nov 19 2014 02:55
italics!
Joe Elsey
@joeelsey
Nov 19 2014 02:57
lol.
I'm full of fanstastic ideas I can't act on. hence programming class
Mark Harrell
@ecjs
Nov 19 2014 02:57
haha!
Joe Elsey
@joeelsey
Nov 19 2014 03:18
Did I overhear earlier we don't like find by id?
Mark Harrell
@ecjs
Nov 19 2014 03:18
nope find by id is great
its findoneandupdate
that sucks
Joe Elsey
@joeelsey
Nov 19 2014 03:18
ah
Mark Harrell
@ecjs
Nov 19 2014 03:18
IMO
Chareesa Graham
@Chareesa
Nov 19 2014 03:23
findOne() is goood
wasn't there something else?
in regards to the findOne..
something to do with.. put? I dunno
Joe Elsey
@joeelsey
Nov 19 2014 03:30
well change phone still times out
I tried changing it to a put that uses the user name to find and still nothing.
Joe Elsey
@joeelsey
Nov 19 2014 03:34
LOL!
Mark Harrell
@ecjs
Nov 19 2014 03:34
:P
Joe Elsey
@joeelsey
Nov 19 2014 03:35
no hype :)
Mark Harrell
@ecjs
Nov 19 2014 03:35
nahhhhhh
Joe Elsey
@joeelsey
Nov 19 2014 03:36
So out of 15 tests change a phone number and change a password are the only ones I can't get to work tonight. Any chance we can look at these tomorrow?
Mark Harrell
@ecjs
Nov 19 2014 03:36
no probs
Chareesa Graham
@Chareesa
Nov 19 2014 03:36
definitely
Sendgrid is up
Mark Harrell
@ecjs
Nov 19 2014 03:37
awesome
Chareesa Graham
@Chareesa
Nov 19 2014 03:37
My first shot was a miss
looking through some docs
Joe Elsey
@joeelsey
Nov 19 2014 03:40
cool. I'm going to bug out then.
Mark Harrell
@ecjs
Nov 19 2014 03:40
sounds good!
Chareesa Graham
@Chareesa
Nov 19 2014 03:43
safe travels!
Mark Harrell
@ecjs
Nov 19 2014 03:43
o hey guys
btw
you have emails now
Chareesa Graham
@Chareesa
Nov 19 2014 03:43
haha
Chareesa Graham
@Chareesa
Nov 19 2014 03:43
chareesa@secretconciergeapp.co
for login
passwords are set to: password
free accounts thx to zoho
Chareesa Graham
@Chareesa
Nov 19 2014 03:44
saw that, nice!
Mark Harrell
@ecjs
Nov 19 2014 03:45
I have the support account setup
eventually we will have that hooked into a pretty support system like zendesk
;)
how to set it up on your iphone
joe how to setup on android: http://zsync.zohosites.com/Android.html
at least now we are like..official
vincent..i hope you have an iphone
@vlee90 your username is vincent@conciergeapp.co
login with password: password
all set
:P
Chareesa Graham
@Chareesa
Nov 19 2014 03:49
omfg
"{ message: 'success' }"
gonna go see if this means what I think it means..
Mark Harrell
@ecjs
Nov 19 2014 03:49
LOL
of course it does
SUCCESSSSS
Chareesa Graham
@Chareesa
Nov 19 2014 03:49
guys... GUSY!!
MARK
Here is your new password for Concierge: ErV6OsQN
yaaaa
And of course my computer FROZE just as I refreshed and saw it sitting there in my inbox.
what a jerk computer
okay, I need to push this shizznit
Mark Harrell
@ecjs
Nov 19 2014 03:50
LOL
Chareesa Graham
@Chareesa
Nov 19 2014 03:50
I added a little snip on top after the Sengrid requirement
Mark Harrell
@ecjs
Nov 19 2014 03:51
NICE!!!
Chareesa Graham
@Chareesa
Nov 19 2014 03:54
actually.. I realized that I used the jwt token to do this..
Mark Harrell
@ecjs
Nov 19 2014 03:55
yah, you dont need that
Chareesa Graham
@Chareesa
Nov 19 2014 03:55
and when I used the username, it said I was unauthorized
i mean "access denied"
Mark Harrell
@ecjs
Nov 19 2014 03:55
just remove jwtauth
Chareesa Graham
@Chareesa
Nov 19 2014 03:55
ok
Mark Harrell
@ecjs
Nov 19 2014 03:55
from the middleware
well wait..
hmmmm
paste your code in here
using ```
Chareesa Graham
@Chareesa
Nov 19 2014 03:55
one sec
pretty much the same you sent me.
'use strict';

var User = require('../models/user_model');
var sendgrid = require('sendgrid')(process.env.api_user, process.env.api_key);

module.exports = function(app, jwtauth) {
  var generatePassword = function() {
    var length = 8;
    var charset = 'abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
    var retVal = '';
    for (var i = 0, n = charset.length; i < length; ++i) {
      retVal += charset.charAt(Math.floor(Math.random() * n));
    }
    return retVal;
  };
  app.get('/passwordReset', function(req, res) {
    User.findOne({username: req.user.username}, function(err, user) {
      if (err) return res.status(500).send('there was an error' + err);
      user.password = generatePassword();
      user.save(function(err) {
        if (err) return res.status(500).send('there was an error' + err);
      });
      sendgrid.send({
        to:       user.username,
        from:     'chareesaaguilar@gmail.com',
        subject:  'Password Reset for Concierge',
        text:     'Here is your new password for Concierge: ' + user.password
      }, function(err, json) {
        if (err) { return console.error(err); }
        console.log(json);
      });
    });
  });
};
I took out the jwtauth and now it says
"TypeError: Cannot read property &#39;username&#39; of undefined<br>    at /Users/user/Documents/devAccelerator/Concierge/route"
Mark Harrell
@ecjs
Nov 19 2014 03:57
because of this
Chareesa Graham
@Chareesa
Nov 19 2014 03:57
/password_reset.js:17:37
Mark Harrell
@ecjs
Nov 19 2014 03:57
req.user.username
Chareesa Graham
@Chareesa
Nov 19 2014 03:57
oh
Mark Harrell
@ecjs
Nov 19 2014 03:57
what you need to do
Chareesa Graham
@Chareesa
Nov 19 2014 03:57
need id
Mark Harrell
@ecjs
Nov 19 2014 03:57
is use
req.body.username
nope you can use username
that way..they have to type in their username to get their password sent to them
actually
yah that works
just have them type in their username, and we will send their reset password to their email
Chareesa Graham
@Chareesa
Nov 19 2014 03:59
hmm.. routes/password_reset.js:19
user.password = generatePassword();
^
TypeError: Cannot set property 'password' of null
Mark Harrell
@ecjs
Nov 19 2014 03:59
so basically
when it says that
most likely isnt finding the user with that username
you need to send in the email via a post/json
in something like postman
so send username: userid@example.com
or whatever email you have
that should work.
Chareesa Graham
@Chareesa
Nov 19 2014 04:01
I can't create a new user
anymore
Mark Harrell
@ecjs
Nov 19 2014 04:01
why?
Chareesa Graham
@Chareesa
Nov 19 2014 04:02
oh user error. I'll play a little with this
Mark Harrell
@ecjs
Nov 19 2014 04:02
ok
Mark Harrell
@ecjs
Nov 19 2014 04:26
var superagent = require('superagent');
var moment = require('moment');
var agent = superagent.agent();
var agent2 = superagent.agent();
var agent3 = superagent.agent();
var agent4 = superagent.agent();
var agent5 = superagent.agent();
var userPhone = '3607393580';
var conciergePhone = '5202227925';
var userJWT;
var conciergeJWT;
function makeUsers()  {
  agent
  .post('https://salty-earth-1782.herokuapp.com/users')
  .send({username: 'test@example.com', password: 'Foobar123', name: {first:'Mark', last: 'Harrell'}, phone: userPhone})
  .set('Content-Type', 'application/json')
  .end(function(err, superRes) {
    if (err) return console.log('did not populate' + err + ' ' + superRes);
    userJWT = superRes.body.jwt;
    console.log(userJWT);
    agent
    .post('https://salty-earth-1782.herokuapp.com/jobs')
    .send({jobDate: moment().add(20, 'hours').utc().format(), recurring: true})
    .set('Content-Type', 'application/json')
    .set('jwt', userJWT)
    .end(function(err, superRes) {
      if (err) return console.log('did not populate' + err + ' ' + superRes);
      console.log(superRes.body);
    });
  });

  agent2
  .post('https://salty-earth-1782.herokuapp.com/users')
  .send({username: 'test1@example.com', password: 'Foobar123', name: {first:'Mark', last: 'Harrell'}, phone: conciergePhone})
  .set('Content-Type', 'application/json')
  .end(function(err, superRes) {
    if (err) return console.log('did not populate' + err + ' ' + superRes);
    conciergeJWT = superRes.body.jwt;
    console.log('concierge jwt: ' + conciergeJWT);
    agent3
    .post('https://salty-earth-1782.herokuapp.com/concierge')
    .send()
    .set('Content-Type', 'application/json')
    .set('jwt', conciergeJWT)
    .end(function(err2, superRes2) {
      if (err) return console.log('did not populate' + err + ' ' + superRes2);
    });
    agent4
    .post('https://salty-earth-1782.herokuapp.com/conciergeAvailable')
    .send()
    .set('Content-Type', 'application/json')
    .set('jwt', conciergeJWT)
    .end(function(err2, superRes2) {
      if (err) return console.log('did not populate' + err + ' ' + superRes2);
      conciergeJWT = superRes2.body.jwt;
    });
  });
}

makeUsers();
not sure if thats the best code but it works
make sure to set your variables
Chareesa Graham
@Chareesa
Nov 19 2014 04:46
haha, Mark..
the javascript chat
Mark Harrell
@ecjs
Nov 19 2014 04:46
lol
:P
Chareesa Graham
@Chareesa
Nov 19 2014 06:09
In the user model, under jobs.. do we need to add job details? I'm looking into deleting a job and am trying to think about how to go about it.
Mark Harrell
@ecjs
Nov 19 2014 06:10
what do you mean?
what kind of job details..
Chareesa Graham
@Chareesa
Nov 19 2014 06:11
Oh... it just auto populates with this info?
var newJob = new Job({
      jobDate: req.body.jobDate,
      parent: req.user._id,
      recurring: req.body.recurring,
      parentName: req.user.name,
      parentNumber: req.user.phone
    });
I'm looking for what to grab when trying to delete a user job
Mark Harrell
@ecjs
Nov 19 2014 06:12
to delete a job, you are going to want to grab the jobs id
which we will provide in the get request for all of the jobs
so findById will work great there
Chareesa Graham
@Chareesa
Nov 19 2014 06:13
ahh
Chareesa Graham
@Chareesa
Nov 19 2014 06:28
has there been no commits to dev since we were at code fellows? I'm doing git fetch and not getting anything.
Mark Harrell
@ecjs
Nov 19 2014 06:28
hmm
I dont think so
I have been working on the concierge jobs get
having issues gathering all of those jobs
Chareesa Graham
@Chareesa
Nov 19 2014 06:30
ah ok
Mark Harrell
@ecjs
Nov 19 2014 07:25
chareesa, your pull request was sent to master..
not to dev
so it looks kind of crazy
ok guys, I made an update to the concierge jobs
the get request is working now
to the concierge can see a list of all the jobs that he/she is currently queued for.
Mark Harrell
@ecjs
Nov 19 2014 07:32
so when you get a chance, go ahead and get even with the upstream/dev
Chareesa Graham
@Chareesa
Nov 19 2014 15:30
what, I could have sworn it was dev
ugh
got it now
Chareesa Graham
@Chareesa
Nov 19 2014 16:26

For the phone number, I tried it again and got this (it works):

{ "_id" : ObjectId("546c1669f10624809a0bfb70"), "confirmationCode" : "272828", "username" : "chareesa@tagcreativestudio.com", "password" : "$2a$05$4f1Bvqq68/Hr0v91iGzwpeWuWndIW0gnwBPgxTOU/pTHvuVVFhiea", "phone" : "5035020322", "confirmed" : false, "jobs" : [ ], "conciergeJobs" : [ ], "name" : { "first" : "chareesa", "last" : "anything" }, "__v" : 0 }
> db.users.find()
{ "_id" : ObjectId("546c0d8d93756c4a92890952"), "confirmationCode" : "845760", "username" : "chareesagraham@gmail.com", "password" : "$2a$05$9k1u6TrdYC7BFo9e3kq7KeDhLmFv/nnNhd7fAbqBbI8MmMA35Y9Mm", "phone" : "5035020322", "confirmed" : false, "jobs" : [ ], "conciergeJobs" : [ ], "name" : { "first" : "chareesa", "last" : "anything" }, "__v" : 0 }
{ "_id" : ObjectId("546c1669f10624809a0bfb70"), "confirmationCode" : "321478", "username" : "chareesa@tagcreativestudio.com", "password" : "$2a$05$4f1Bvqq68/Hr0v91iGzwpeWuWndIW0gnwBPgxTOU/pTHvuVVFhiea", "phone" : "9715338049", "confirmed" : false, "jobs" : [ ], "conciergeJobs" : [ ], "name" : { "first" : "chareesa", "last" : "anything" }, "__v" : 0 }

Changed chareesa@tagcreativestudio.com's phone #

Joe Elsey
@joeelsey
Nov 19 2014 17:46
var moment = require('moment');
console.log(moment().utc().format());
you'll need to npm install moment js. use node to run and it will spit out a utc time to the console.