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/seed/challenges/bootstrap.json b/seed/challenges/bootstrap.json
index da7a510236..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 your div class=\"well\">
element both with the class col-xs-6
')",
+ "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.')"
],
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..2dd6a4b90d 100644
--- a/server/utils/auth.js
+++ b/server/utils/auth.js
@@ -1,5 +1,20 @@
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) {
+ 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