From 007f9135173bf84e7105e411ceef84b167100e90 Mon Sep 17 00:00:00 2001 From: Allan Hernandez Date: Fri, 21 Aug 2015 16:17:21 -0500 Subject: [PATCH 1/4] Confusing Wells Text - #2391 #2458 Checklist instructions were incorrect as seen in closes #2391 closes #2458 --- seed/challenges/bootstrap.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seed/challenges/bootstrap.json b/seed/challenges/bootstrap.json index da7a510236..c814fcf8dd 100644 --- a/seed/challenges/bootstrap.json +++ b/seed/challenges/bootstrap.json @@ -1769,7 +1769,7 @@ "Nest one div element with the class well within each of your col-xs-6 div elements." ], "tests": [ - "assert($(\"div\").length > 4, 'Add two div elements inside your div class=\"well\"> element both with the class col-xs-6')", + "assert($(\"div\").length > 4, 'Add two div elements inside each of your div class=\"col-xs-6\"> elements both with the class well')", "assert($(\"div.col-xs-6\").children(\"div.well\").length > 1, 'Nest both of your div class=\"col-xs-6\" elements within your div class=\"row\" element.')", "assert(editor.match(/<\\/div>/g) && editor.match(/
/g).length === editor.match(/
div elements have closing tags.')" ], From 1c2748b623a129d32d0117816569af12c9a57117 Mon Sep 17 00:00:00 2001 From: Allan Hernandez Date: Fri, 21 Aug 2015 16:35:14 -0500 Subject: [PATCH 2/4] Update bootstrap.json Clarifying - Agree with @BerkeleyTrue on clarity --- seed/challenges/bootstrap.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seed/challenges/bootstrap.json b/seed/challenges/bootstrap.json index c814fcf8dd..34b5451572 100644 --- a/seed/challenges/bootstrap.json +++ b/seed/challenges/bootstrap.json @@ -1769,7 +1769,7 @@ "Nest one div element with the class well within each of your col-xs-6 div elements." ], "tests": [ - "assert($(\"div\").length > 4, 'Add two div elements inside each of your div class=\"col-xs-6\"> elements both with the class well')", + "assert($(\"div\").length > 4, 'Add a div element with the class well inside each of your div class=\"col-xs-6\"> elements')", "assert($(\"div.col-xs-6\").children(\"div.well\").length > 1, 'Nest both of your div class=\"col-xs-6\" elements within your div class=\"row\" element.')", "assert(editor.match(/<\\/div>/g) && editor.match(/
/g).length === editor.match(/
div elements have closing tags.')" ], From 0f3acc629c553ac77c4234fe7fa676aeea0b4677 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Fri, 21 Aug 2015 16:08:49 -0700 Subject: [PATCH 3/4] fix profile linking --- common/models/User-Identity.js | 14 +++++++------- server/boot/a-extendUserIdent.js | 2 +- server/boot/user.js | 10 +++++----- server/server.js | 6 +++++- server/utils/auth.js | 16 ++++++++++++++++ server/views/account/show.jade | 6 +++--- 6 files changed, 37 insertions(+), 17 deletions(-) diff --git a/common/models/User-Identity.js b/common/models/User-Identity.js index 3b1bcb8750..a6c5241043 100644 --- a/common/models/User-Identity.js +++ b/common/models/User-Identity.js @@ -4,12 +4,13 @@ import debugFactory from 'debug'; import { setProfileFromGithub, getFirstImageFromProfile, + getUsernameFromProvider, getSocialProvider } from '../../server/utils/auth'; -const debug = debugFactory('freecc:models:userIdent'); - const { defaultProfileImage } = require('../utils/constantStrings.json'); +const githubRegex = (/github/i); +const debug = debugFactory('freecc:models:userIdent'); function createAccessToken(user, ttl, cb) { if (arguments.length === 2 && typeof ttl === 'function') { @@ -158,14 +159,13 @@ export default function(UserIdent) { userChanged = true; } - if (!(/github/).test(provider) && profile) { - debug('setting social', provider, (/github/g).test(provider)); - debug('profile username', profile.username); - user[provider] = profile.username; + if (!githubRegex.test(provider) && profile) { + user[provider] = getUsernameFromProvider(provider, profile); + userChanged = true; } // if user signed in with github refresh their info - if (/github/.test(provider) && profile && profile._json) { + if (githubRegex.test(provider) && profile && profile._json) { debug("user isn't github cool or username from github is different"); setProfileFromGithub(user, profile, profile._json); userChanged = true; diff --git a/server/boot/a-extendUserIdent.js b/server/boot/a-extendUserIdent.js index 1fac91d85e..7114e1b53f 100644 --- a/server/boot/a-extendUserIdent.js +++ b/server/boot/a-extendUserIdent.js @@ -54,7 +54,7 @@ export default function({ models }) { } identity.credentials = credentials; return observeQuery(identity, 'updateAttributes', { - profile: getSocialProvider(provider), + profile, credentials, modified }); diff --git a/server/boot/user.js b/server/boot/user.js index 158882abc5..33a80c5c62 100644 --- a/server/boot/user.js +++ b/server/boot/user.js @@ -194,11 +194,11 @@ module.exports = function(app) { isMigrationGrandfathered: user.isMigrationGrandfathered, isGithubCool: user.isGithubCool, location: user.location, - githubProfile: user.github, - linkedinProfile: user.linkedin, - googleProfile: user.google, - facebookProfile: user.facebook, - twitterHandle: user.twitter, + github: user.githubURL, + linkedin: user.linkedin, + google: user.google, + facebook: user.facebook, + twitter: user.twitter, picture: user.picture, progressTimestamps: user.progressTimestamps, calender: data, diff --git a/server/server.js b/server/server.js index 49b5825522..16fe784113 100755 --- a/server/server.js +++ b/server/server.js @@ -12,6 +12,7 @@ var uuid = require('node-uuid'), var setProfileFromGithub = require('./utils/auth').setProfileFromGithub; var getSocialProvider = require('./utils/auth').getSocialProvider; +var getUsernameFromProvider = require('./utils/auth').getUsernameFromProvider; var generateKey = require('loopback-component-passport/lib/models/utils').generateKey; @@ -69,7 +70,10 @@ var passportOptions = { } if (!(/github/).test(provider)) { - userObj[getSocialProvider(provider)] = profile.username; + userObj[getSocialProvider(provider)] = getUsernameFromProvider( + getSocialProvider(provider), + profile + ); } if (/github/.test(provider)) { diff --git a/server/utils/auth.js b/server/utils/auth.js index fd7905027d..bc23a8634e 100644 --- a/server/utils/auth.js +++ b/server/utils/auth.js @@ -1,5 +1,21 @@ import assign from 'object.assign'; +const providerHash = { + facebook: ({ id }) => id, + twitter: ({ username }) => username, + linkedin({ _json }) { + return _json && _json.publicProfileUrl || null; + }, + google: ({ id }) => id +}; + +export function getUsernameFromProvider(provider, profile) { + console.log(profile); + return typeof providerHash[provider] === 'function' ? + providerHash[provider](profile) : + null; +} + // using es6 argument destructing export function setProfileFromGithub( user, diff --git a/server/views/account/show.jade b/server/views/account/show.jade index 4c837f828d..c559f84aa3 100644 --- a/server/views/account/show.jade +++ b/server/views/account/show.jade @@ -24,15 +24,15 @@ block content img.img-center.img-responsive.public-profile-img(src='https://s3.amazonaws.com/freecodecamp/camper-image-placeholder.png') h1.text-center.negative-5.profile-social-icons if (twitter) - a.fa.fa-twitter-square.text-primary(title="@#{username}'s Twitter Profile", href=twitter, target='_blank') + a.fa.fa-twitter-square.text-primary(title="@#{username}'s Twitter Profile", href='https://twitter.com/' + twitter, target='_blank') if (github) a.fa.fa-github-square.text-primary(title="@#{username}'s GitHub Profile", href=github, target='_blank') if (linkedin) a.fa.fa-linkedin-square.text-primary(title="@#{username}'s LinkedIn Profile", href=linkedin, target='_blank') if (facebook) - a.fa.fa-facebook-square.text-primary(title="@#{username}'s Facebook Profile", href=facebook, target='_blank') + a.fa.fa-facebook-square.text-primary(title="@#{username}'s Facebook Profile", href='https://facebook.com/' + facebook, target='_blank') if (google) - a.fa.fa-google-square.text-primary(title="@#{username}'s Google Profile", href=google, target='_blank') + a.fa.fa-google-plus-square.text-primary(title="@#{username}'s Google Profile", href='https://plus.google.com/' + google, target='_blank') .visible-md.visible-lg .col-xs-12.col-sm-12.col-md-4.text-justify h1.flat-top.wrappable= name From f5a652e046d988fd8669b24c907dd609816885eb Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Fri, 21 Aug 2015 16:09:50 -0700 Subject: [PATCH 4/4] fix remove console log --- server/utils/auth.js | 1 - 1 file changed, 1 deletion(-) diff --git a/server/utils/auth.js b/server/utils/auth.js index bc23a8634e..2dd6a4b90d 100644 --- a/server/utils/auth.js +++ b/server/utils/auth.js @@ -10,7 +10,6 @@ const providerHash = { }; export function getUsernameFromProvider(provider, profile) { - console.log(profile); return typeof providerHash[provider] === 'function' ? providerHash[provider](profile) : null;