Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Started Confirm Email Step

  • Loading branch information...
commit 62720d398de337bc344c915f58689a21921c1dc8 1 parent c810f92
@dstroot authored
View
1  .gitattributes
@@ -0,0 +1 @@
+* text=auto
View
1  app.js
@@ -149,6 +149,7 @@ app.use(passport.session());
app.use(function(req, res, next) {
res.locals.user = req.user;
res.locals.token = req.csrfToken();
+ res.locals.config = config;
next();
});
View
40 config/passport.js
@@ -195,20 +195,34 @@ passport.use(new TwitterStrategy(config.twitter, function(req, accessToken, toke
}
});
return done(null, existingUser);
+ } else {
+ // TODO
+
+ // Ideally here we would grab all thier data and save it into the session
+ // then go to another page where they can enter/confirm their email address
+ // THEN save their account
+ // ===========================================================
+ // // Save their profile data into the session
+ // req.session.socialProfile = profile;
+ // // Twitter does NOT provide an email address
+ // res.render('account/confirmEmail', { email: 'dan@thestroots.com' });
+ // ========= this would move the steps below until the next page
+
+ // BRAND NEW USER!
+ var user = new User();
+ // Twitter will not provide an email address. Period.
+ // But a person’s twitter username is guaranteed to be unique
+ // so we can "fake" a twitter email address as follows:
+ user.email = profile.username + '@twitter.com';
+ user.twitter = profile.id;
+ user.tokens.push({ kind: 'twitter', accessToken: accessToken, tokenSecret: tokenSecret });
+ user.profile.name = profile.displayName;
+ user.profile.location = profile._json.location;
+ user.profile.picture = profile._json.profile_image_url;
+ user.save(function(err) {
+ done(err, user);
+ });
}
- var user = new User();
- // Twitter will not provide an email address. Period.
- // But a person’s twitter username is guaranteed to be unique
- // so we can "fake" a twitter email address as follows:
- user.email = profile.username + '@twitter.com';
- user.twitter = profile.id;
- user.tokens.push({ kind: 'twitter', accessToken: accessToken, tokenSecret: tokenSecret });
- user.profile.name = profile.displayName;
- user.profile.location = profile._json.location;
- user.profile.picture = profile._json.profile_image_url;
- user.save(function(err) {
- done(err, user);
- });
});
}
}));
View
130 controllers/account.js
@@ -0,0 +1,130 @@
+'use strict';
+
+/**
+ * Module Dependences
+ */
+
+var _ = require('underscore');
+var User = require('../models/User');
+var passportConf = require('../config/passport');
+
+/**
+ * Account Controller
+ */
+
+module.exports.controller = function(app) {
+
+ /**
+ * GET /account
+ * Render User Profile Page
+ */
+
+ app.get('/account', passportConf.isAuthenticated, function(req, res) {
+ res.render('account/profile', {
+ url: req.url
+ });
+ });
+
+ /**
+ * POST /account
+ * Update User Profile Information
+ */
+
+ app.post('/account/profile', passportConf.isAuthenticated, function(req, res, next) {
+ User.findById(req.user.id, function(err, user) {
+ if (err) {
+ return next(err);
+ }
+ user.email = req.body.email || '';
+ user.profile.name = req.body.name || '';
+ user.profile.gender = req.body.gender || '';
+ user.profile.location = req.body.location || '';
+ user.profile.website = req.body.website || '';
+ user.activity.last_updated = Date.now();
+
+ user.save(function(err) {
+ if (err) {
+ return next(err);
+ }
+ req.flash('success', { msg: 'Profile information updated.' });
+ res.redirect('/account');
+ });
+ });
+ });
+
+ /**
+ * POST /account/password
+ * Update User Password
+ */
+
+ app.post('/account/password', passportConf.isAuthenticated, function(req, res, next) {
+ req.assert('password', 'Password must be at least 4 characters long').len(4);
+ req.assert('confirmPassword', 'Passwords do not match').equals(req.body.password);
+ var errors = req.validationErrors();
+
+ if (errors) {
+ req.flash('errors', errors);
+ return res.redirect('/account');
+ }
+
+ User.findById(req.user.id, function(err, user) {
+ if (err) {
+ return next(err);
+ }
+
+ user.password = req.body.password;
+ user.activity.last_updated = Date.now();
+
+ user.save(function(err) {
+ if (err) {
+ return next(err);
+ }
+ req.flash('success', { msg: 'Password has been changed.' });
+ res.redirect('/account');
+ });
+ });
+
+ });
+
+ /**
+ * POST /account/delete
+ * Delete User Account
+ */
+
+ app.post('/account/delete', passportConf.isAuthenticated, function(req, res, next) {
+ User.remove({ _id: req.user.id }, function(err) {
+ if (err) {
+ return next(err);
+ }
+ req.logout();
+ res.redirect('/');
+ });
+ });
+
+ /**
+ * GET /account/unlink/:provider
+ * Unlink a social account
+ */
+
+ app.get('/account/unlink/:provider', passportConf.isAuthenticated, function(req, res, next) {
+ var provider = req.params.provider;
+ User.findById(req.user.id, function(err, user) {
+ if (err) {
+ return next(err);
+ }
+
+ user[provider] = undefined;
+ user.tokens = _.reject(user.tokens, function(token) { return token.kind === provider; });
+ user.activity.last_updated = Date.now();
+
+ user.save(function(err) {
+ if (err) {
+ return next(err);
+ }
+ req.flash('info', { msg: provider + ' account has been unlinked.' });
+ res.redirect('/account');
+ });
+ });
+ });
+
+};
View
2  controllers/api.js
@@ -248,7 +248,7 @@ module.exports.controller = function(app) {
};
twilio.sendMessage(message, function(err, responseData) {
if (err) {
- return next(err.message);
+ return next(err);
}
req.flash('success', { msg: 'Text sent to ' + responseData.to + '.'});
res.redirect('/api/twilio');
View
91 controllers/user.js
@@ -4,9 +4,7 @@
* Module Dependencies
*/
-var _ = require('underscore');
var passport = require('passport');
-var passportConf = require('../config/passport');
var User = require('../models/User');
/**
@@ -112,95 +110,6 @@ module.exports.controller = function(app) {
});
- app.get('/account', passportConf.isAuthenticated, function(req, res) {
- res.render('account/profile', {
- url: req.url
- });
- });
-
- app.post('/account/profile', passportConf.isAuthenticated, function(req, res, next) {
- User.findById(req.user.id, function(err, user) {
- if (err) {
- return next(err);
- }
- user.email = req.body.email || '';
- user.profile.name = req.body.name || '';
- user.profile.gender = req.body.gender || '';
- user.profile.location = req.body.location || '';
- user.profile.website = req.body.website || '';
- user.activity.last_updated = Date.now();
-
- user.save(function(err) {
- if (err) {
- return next(err);
- }
- req.flash('success', { msg: 'Profile information updated.' });
- res.redirect('/account');
- });
- });
- });
-
- app.post('/account/password', passportConf.isAuthenticated, function(req, res, next) {
- req.assert('password', 'Password must be at least 4 characters long').len(4);
- req.assert('confirmPassword', 'Passwords do not match').equals(req.body.password);
- var errors = req.validationErrors();
-
- if (errors) {
- req.flash('errors', errors);
- return res.redirect('/account');
- }
-
- User.findById(req.user.id, function(err, user) {
- if (err) {
- return next(err);
- }
-
- user.password = req.body.password;
- user.activity.last_updated = Date.now();
-
- user.save(function(err) {
- if (err) {
- return next(err);
- }
- req.flash('success', { msg: 'Password has been changed.' });
- res.redirect('/account');
- });
- });
-
- });
-
- app.post('/account/delete', passportConf.isAuthenticated, function(req, res, next) {
- User.remove({ _id: req.user.id }, function(err) {
- if (err) {
- return next(err);
- }
- req.logout();
- res.redirect('/');
- });
- });
-
-
- app.get('/account/unlink/:provider', passportConf.isAuthenticated, function(req, res, next) {
- var provider = req.params.provider;
- User.findById(req.user.id, function(err, user) {
- if (err) {
- return next(err);
- }
-
- user[provider] = undefined;
- user.tokens = _.reject(user.tokens, function(token) { return token.kind === provider; });
- user.activity.last_updated = Date.now();
-
- user.save(function(err) {
- if (err) {
- return next(err);
- }
- req.flash('info', { msg: provider + ' account has been unlinked.' });
- res.redirect('/account');
- });
- });
- });
-
/**
* OAuth routes for sign-in.
*/
View
2  gulpfile.js
@@ -151,7 +151,7 @@ gulp.task('scripts', function() {
gulp.task('images', function() {
gulp.src(paths.images) // Read images
- // .pipe(changed(paths.images)) // Only process new/changed
+ .pipe(changed(paths.images)) // Only process new/changed
.pipe(imagemin({ optimizationLevel: 5, progressive: true, interlaced: true }))
.pipe(gulp.dest('./public/img')) // Write processed images
.pipe(notify({ onLast: true, message: 'Images task complete' }));
View
2  package.json
@@ -1,6 +1,6 @@
{
"private": true,
- "version": "0.0.1-40",
+ "version": "0.0.1-41",
"name": "Skeleton",
"company": "Skeleton, Inc.",
"subdomain": "skeleton-app",
View
2  public/css/Skeleton.min.css
@@ -1,6 +1,6 @@
/**
* Skeleton - A friendly node and express framework
- * @version v0.0.1-40
+ * @version v0.0.1-41
* @link http://skeleton-app.jit.su
* @license
*/
View
14 public/humans.txt
@@ -1,21 +1,19 @@
-/* the humans responsible for building ViziLinkz.com */
+/* the humans responsible for building Skeleton.com */
/* TEAM */
- Designer + Coder: Dan Stroot (heavily based on Dan Grossman's Bookmarkly)
+ Designer + Coder: Dan Stroot
Site: danstroot.com
- Contact: dan.stroot[at]gmail.com **Feel free to say hi.
+ Contact: dan.stroot[at]gmail.com
Location: California, USA
/* THANKS */
- Bootstrap (http://html5boilerplate.com/) *This really helps... you should try it too
+ Bootstrap (http://getbootstrap.com/)
jQuery (http://jquery.com/)
- Lettering.js (http://letteringjs.com/) *Made by the awesome guys at http://paravelinc.com
- Modernizr (http://www.modernizr.com/)
+ etc.
/* SITE */
Standards: HTML5, CSS3
- Components: Modernizr, jQuery, HTML5 Boilerplate, Lettering.js
- Software: Notepad++, Photoshop
+ Components: jQuery, Bootstrap, FontAwesome, etc.
View
2  public/js/Skeleton.min.js
@@ -1,6 +1,6 @@
/**
* Skeleton - A friendly node and express framework
- * @version v0.0.1-40
+ * @version v0.0.1-41
* @link http://skeleton-app.jit.su
* @license
*/
View
2  public/js/Skeleton.min.js.map
@@ -1,6 +1,6 @@
/**
* Skeleton - A friendly node and express framework
- * @version v0.0.1-40
+ * @version v0.0.1-41
* @link http://skeleton-app.jit.su
* @license
*/
View
17 views/account/confirmEmail.jade
@@ -0,0 +1,17 @@
+extends ../layouts/layout
+
+block content
+ .container
+ .row
+ .col-sm-6.col-sm-offset-3
+ .page-header
+ h1 Complete Sign Up!
+ form(method='POST')
+ input(type='hidden', name='_csrf', value=token)
+ .form-group
+ label.sr-only(for='email') Confirm Your Email Address:
+ input.form-control(type='email', name='email', value='#{title}', placeholder='Your Email Address', autofocus=true, required)
+ .form-group
+ button.btn.btn-primary.btn-reset(type='submit') Create My Account!
+ hr
+ p We only use this information when necessary. We will <strong>never</strong> spam you.
View
37 views/account/login.jade
@@ -11,18 +11,23 @@ block content
legend Sign In
.form-group
.btn-group.btn-group-vertical(style='width:100%')
- a.btn.btn-facebook.btn-lg(href='/auth/facebook')
- i.fa.fa-fw.fa-facebook
- | &nbsp;Sign in with Facebook
- a.btn.btn-twitter.btn-lg(href='/auth/twitter')
- i.fa.fa-fw.fa-twitter
- | &nbsp;Sign in with Twitter
- a.btn.btn-github.btn-lg(href='/auth/github')
- i.fa.fa-fw.fa-github
- | &nbsp;Sign in with GitHub
- a.btn.btn-google.btn-lg(href='/auth/google')
- i.fa.fa-fw.fa-google-plus
- | &nbsp;Sign in with Google
+ if config.facebookAuth
+ a.btn.btn-facebook.btn-lg(href='/auth/facebook')
+ i.fa.fa-fw.fa-facebook
+ | &nbsp;Sign in with Facebook
+ if config.twitterAuth
+ a.btn.btn-twitter.btn-lg(href='/auth/twitter')
+ i.fa.fa-fw.fa-twitter
+ | &nbsp;Sign in with Twitter
+ if config.githubAuth
+ a.btn.btn-github.btn-lg(href='/auth/github')
+ i.fa.fa-fw.fa-github
+ | &nbsp;Sign in with GitHub
+ if config.googleAuth
+ a.btn.btn-google.btn-lg(href='/auth/google')
+ i.fa.fa-fw.fa-google-plus
+ | &nbsp;Sign in with Google
+ if config.localAuth
hr
#accordion.panel-group
.panel.panel-default
@@ -49,10 +54,10 @@ block content
p Need to
a(href='signup') <strong> sign up</strong>
| for a local #{title} account?
- p I accept #{title}'s
- a(href='/terms') Terms of Use
- | and
- a(href='/privacy') Privacy Policy.
+ p I accept #{title}'s
+ a(href='/terms') Terms of Use
+ | and
+ a(href='/privacy') Privacy Policy.
//- Form Notes
//- ===========================================
View
72 views/account/profile.jade
@@ -46,42 +46,42 @@ block content
.col-sm-4
.page-header
h2 Social Accounts
-
- if user.google
- a.btn.btn-block.btn-google(href='/account/unlink/google')
- i.fa.fa-google-plus.fa-lg.fa-fw
- | &nbsp;Disconnect Google
- else
- a.btn.btn-block.btn-success(href='/auth/google')
- i.fa.fa-google-plus.fa-lg.fa-fw
- | &nbsp;Connect Google
-
- if user.facebook
- a.btn.btn-block.btn-facebook(href='/account/unlink/facebook')
- i.fa.fa-facebook.fa-lg.fa-fw
- | &nbsp;Disconnect Facebook
- else
- a.btn.btn-block.btn-success(href='/auth/facebook')
- i.fa.fa-facebook.fa-lg.fa-fw
- | &nbsp;Connect Facebook
-
- if user.twitter
- a.btn.btn-block.btn-twitter(href='/account/unlink/twitter')
- i.fa.fa-twitter.fa-lg.fa-fw
- | &nbsp;Disconnect Twitter
- else
- a.btn.btn-block.btn-success(href='/auth/twitter')
- i.fa.fa-twitter.fa-lg.fa-fw
- | &nbsp;Connect Twitter
-
- if user.github
- a.btn.btn-block.btn-github(href='/account/unlink/github')
- i.fa.fa-github.fa-lg.fa-fw
- | &nbsp;Disconnect GitHub
- else
- a.btn.btn-block.btn-success(href='/auth/github')
- i.fa.fa-github.fa-lg.fa-fw
- | &nbsp;Connect GitHub
+ if config.facebookAuth
+ if user.facebook
+ a.btn.btn-block.btn-facebook(href='/account/unlink/facebook')
+ i.fa.fa-facebook.fa-lg.fa-fw
+ | &nbsp;Disconnect Facebook
+ else
+ a.btn.btn-block.btn-success(href='/auth/facebook')
+ i.fa.fa-facebook.fa-lg.fa-fw
+ | &nbsp;Connect Facebook
+ if config.twitterAuth
+ if user.twitter
+ a.btn.btn-block.btn-twitter(href='/account/unlink/twitter')
+ i.fa.fa-twitter.fa-lg.fa-fw
+ | &nbsp;Disconnect Twitter
+ else
+ a.btn.btn-block.btn-success(href='/auth/twitter')
+ i.fa.fa-twitter.fa-lg.fa-fw
+ | &nbsp;Connect Twitter
+ if config.githubAuth
+ if user.github
+ a.btn.btn-block.btn-github(href='/account/unlink/github')
+ i.fa.fa-github.fa-lg.fa-fw
+ | &nbsp;Disconnect GitHub
+ else
+ a.btn.btn-block.btn-success(href='/auth/github')
+ i.fa.fa-github.fa-lg.fa-fw
+ | &nbsp;Connect GitHub
+ if config.googleAuth
+ if user.google
+ a.btn.btn-block.btn-google(href='/account/unlink/google')
+ i.fa.fa-google-plus.fa-lg.fa-fw
+ | &nbsp;Disconnect Google
+ else
+ a.btn.btn-block.btn-success(href='/auth/google')
+ i.fa.fa-google-plus.fa-lg.fa-fw
+ | &nbsp;Connect Google
.row
.col-sm-6.col-sm-offset-1
.page-header
View
2  views/api/twilio.jade
@@ -25,6 +25,6 @@ block content
input(type='hidden', name='_csrf', value=token)
.form-group
label.sr-only(for='name') Mobile Number:
- input.form-control(type='text', name='telephone', placeholder='Enter Your Mobile Phone Number: +19993334444')
+ input.form-control(type='text', name='telephone', placeholder='Enter *Your* Mobile Phone Number: 9993334444')
.form-group
button.btn.btn-success(type='submit') Send
View
4 views/partials/head.jade
@@ -52,6 +52,7 @@ head
//- Place favicon.ico and apple-touch-icon(s) in the root directory (public/)
//- In app.js make sure app.use(express.favicon(__dirname + '/public/favicon.ico')); is correct.
+
//- Here are the names and sizes needed: (http://mathiasbynens.be/notes/touch-icons)
//- - apple-touch-icon-152x152-precomposed.png
//- - apple-touch-icon-120x120-precomposed.png
@@ -71,5 +72,6 @@ head
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
- ga('create', '#{ga}', '#{url}');
+ ga('create', '#{ga}', 'jit.su');
ga('send', 'pageview');
+
Please sign in to comment.
Something went wrong with that request. Please try again.