Merge branch 'staging' of github.com:FreeCodeCamp/freecodecamp into staging
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import{ Observable } from 'rx';
|
||||
import { observeMethod, observeQuery } from '../utils/rx';
|
||||
import { getSocialProvider } from '../utils/auth';
|
||||
import debugFactory from 'debug';
|
||||
|
||||
const debug = debugFactory('fcc:userIdent');
|
||||
|
||||
export default function({ models }) {
|
||||
const { User, UserIdentity, UserCredential } = models;
|
||||
@@ -20,15 +24,18 @@ export default function({ models }) {
|
||||
options = {};
|
||||
}
|
||||
const user$ = findUserById(userId);
|
||||
console.log('provider', provider);
|
||||
console.log('id', profile.id);
|
||||
findIdent({
|
||||
provider: getSocialProvider(provider),
|
||||
externalId: profile.id
|
||||
})
|
||||
const query = {
|
||||
where: {
|
||||
provider: getSocialProvider(provider),
|
||||
externalId: profile.id
|
||||
}
|
||||
};
|
||||
|
||||
debug('link identity query', query);
|
||||
findIdent(query)
|
||||
.flatMap(identity => {
|
||||
const modified = new Date();
|
||||
if (!identity || identity.externalId !== profile.id) {
|
||||
if (!identity) {
|
||||
return observeQuery(UserIdentity, 'create', {
|
||||
provider: getSocialProvider(provider),
|
||||
externalId: profile.id,
|
||||
@@ -40,6 +47,11 @@ export default function({ models }) {
|
||||
modified
|
||||
});
|
||||
}
|
||||
if (identity.userId !== userId) {
|
||||
return Observable.throw(
|
||||
new Error('An account is already linked to that profile')
|
||||
);
|
||||
}
|
||||
identity.credentials = credentials;
|
||||
return observeQuery(identity, 'updateAttributes', {
|
||||
profile: getSocialProvider(provider),
|
||||
|
@@ -1,5 +1,6 @@
|
||||
var successRedirect = '/';
|
||||
var failureRedirect = '/login';
|
||||
var linkFailureRedirect = '/account';
|
||||
module.exports = {
|
||||
local: {
|
||||
provider: 'local',
|
||||
@@ -34,7 +35,7 @@ module.exports = {
|
||||
callbackURL: '/link/facebook/callback',
|
||||
callbackPath: '/link/facebook/callback',
|
||||
successRedirect: successRedirect,
|
||||
failureRedirect: failureRedirect,
|
||||
failureRedirect: linkFailureRedirect,
|
||||
scope: ['email', 'user_likes'],
|
||||
link: true,
|
||||
failureFlash: true
|
||||
@@ -63,7 +64,7 @@ module.exports = {
|
||||
callbackURL: '/link/google/callback',
|
||||
callbackPath: '/link/google/callback',
|
||||
successRedirect: successRedirect,
|
||||
failureRedirect: failureRedirect,
|
||||
failureRedirect: linkFailureRedirect,
|
||||
scope: ['email', 'profile'],
|
||||
link: true,
|
||||
failureFlash: true
|
||||
@@ -89,7 +90,7 @@ module.exports = {
|
||||
callbackURL: '/link/twitter/callback',
|
||||
callbackPath: '/link/twitter/callback',
|
||||
successRedirect: successRedirect,
|
||||
failureRedirect: failureRedirect,
|
||||
failureRedirect: linkFailureRedirect,
|
||||
consumerKey: process.env.TWITTER_KEY,
|
||||
consumerSecret: process.env.TWITTER_SECRET,
|
||||
link: true,
|
||||
@@ -120,7 +121,7 @@ module.exports = {
|
||||
callbackURL: '/link/linkedin/callback',
|
||||
callbackPath: '/link/linkedin/callback',
|
||||
successRedirect: successRedirect,
|
||||
failureRedirect: failureRedirect,
|
||||
failureRedirect: linkFailureRedirect,
|
||||
clientID: process.env.LINKEDIN_ID,
|
||||
clientSecret: process.env.LINKEDIN_SECRET,
|
||||
scope: ['r_basicprofile', 'r_emailaddress'],
|
||||
@@ -152,7 +153,7 @@ module.exports = {
|
||||
callbackURL: '/auth/github/callback/link',
|
||||
callbackPath: '/auth/github/callback/link',
|
||||
successRedirect: successRedirect,
|
||||
failureRedirect: failureRedirect,
|
||||
failureRedirect: linkFailureRedirect,
|
||||
clientID: process.env.GITHUB_ID,
|
||||
clientSecret: process.env.GITHUB_SECRET,
|
||||
scope: ['email'],
|
||||
|
@@ -34,7 +34,7 @@
|
||||
| .
|
||||
h3 If you've already read the errors and searched Google, you should ask for help.
|
||||
h3 This will take you to our help room.
|
||||
a.btn.btn-lg.btn-primary.btn-block(href='https://gitter.im/FreeCodeCamp/LetsPair', data-dismiss='modal', aria-hidden='true' target='_blank') Take me to the help room
|
||||
a.btn.btn-lg.btn-primary.btn-block(href='https://gitter.im/FreeCodeCamp/help', data-dismiss='modal', aria-hidden='true' target='_blank') Take me to the help room
|
||||
a.btn.btn-lg.btn-info.btn-block(href='#', data-dismiss='modal', aria-hidden='true') Cancel
|
||||
|
||||
#reset-modal.modal(tabindex='-1')
|
||||
|
@@ -1,11 +1,11 @@
|
||||
.row
|
||||
.col-xs-12
|
||||
if messages.errors
|
||||
if (messages.errors || messages.error)
|
||||
.alert.alert-danger.fade.in
|
||||
button.close(type='button', data-dismiss='alert')
|
||||
span.ion-close-circled
|
||||
for error in messages.errors
|
||||
div!= error.msg
|
||||
for error in (messages.errors || messages.error)
|
||||
div!= error.msg || error
|
||||
if messages.info
|
||||
.alert.alert-info.fade.in
|
||||
button.close(type='button', data-dismiss='alert')
|
||||
|
Reference in New Issue
Block a user