Merge remote-tracking branch 'origin/staging' into staging

This commit is contained in:
benmcmahon100
2015-08-22 00:59:34 +01:00
7 changed files with 37 additions and 18 deletions

View File

@ -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;

View File

@ -1769,7 +1769,7 @@
"Nest one <code>div</code> element with the class <code>well</code> within each of your <code>col-xs-6</code> <code>div</code> elements."
],
"tests": [
"assert($(\"div\").length > 4, 'Add two <code>div</code> elements inside your <code>div class=\"well\"></code> element both with the class <code>col-xs-6</code>')",
"assert($(\"div\").length > 4, 'Add a <code>div</code> element with the class <code>well</code> inside each of your <code>div class=\"col-xs-6\"> elements</code>')",
"assert($(\"div.col-xs-6\").children(\"div.well\").length > 1, 'Nest both of your <code>div class=\"col-xs-6\"</code> elements within your <code>div class=\"row\"</code> element.')",
"assert(editor.match(/<\\/div>/g) && editor.match(/<div/g) && editor.match(/<\\/div>/g).length === editor.match(/<div/g).length, 'Make sure all your <code>div</code> elements have closing tags.')"
],

View File

@ -54,7 +54,7 @@ export default function({ models }) {
}
identity.credentials = credentials;
return observeQuery(identity, 'updateAttributes', {
profile: getSocialProvider(provider),
profile,
credentials,
modified
});

View File

@ -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,

View File

@ -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)) {

View File

@ -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,

View File

@ -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