Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit 58310a3

Browse files
authored
Revert "Revert "Add state to the workflow" (#303)" (#304)
This reverts commit c9f041c.
1 parent c9f041c commit 58310a3

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

nodebb-api.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
'use strict';
22

33
var querystring = require('querystring');
4-
var http = require('https');
4+
var http;
5+
if (process.env.NODE_ENV !== 'production') {
6+
http = require('http');
7+
} else {
8+
http = require('https');
9+
}
510
var _ = require('lodash');
611
var util = require('util');
712

@@ -37,6 +42,7 @@ module.exports = function (options) {
3742
path: base_path + 'users/' + target_user + '/external?' + qs
3843
}, function (err, res) {
3944
if (err) return handleErr(err, done);
45+
if (!res.payload) return handleErr(new Error('unexpected error: ' + target_user + res), done);
4046
if (!res.payload.uid) return handleErr(new Error('user not found: ' + target_user), done);
4147
done(null, res.payload.uid);
4248
});
@@ -56,8 +62,10 @@ module.exports = function (options) {
5662
// email: '[email protected]'
5763
// });
5864

59-
data = querystring.stringify(data);
60-
65+
var payload = { username: data.alias ? data.alias : data.name, uid: uid, email: data.email };
66+
if (data.uploadedpicture) payload.uploadedpicture = data.uploadedpicture;
67+
if (data.picture) payload.picture = data.picture;
68+
data = querystring.stringify(payload);
6169
sendReq({
6270
path: base_path + 'users/' + target_user + '?_uid=' + querying_user,
6371
method: 'PUT',

oauth2.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ module.exports = function (options) {
138138
if (!args.user) {
139139
return done(null, {
140140
http$: {
141-
redirect: '/login?redirect=' + args.redirect_uri
141+
// Redirect to the start of the flow, get a new code + crsf token
142+
redirect: '/login?referer=' + encodeURIComponent(process.env.ADULT_FORUM + '/auth/CoderDojo')
142143
}
143144
});
144145
} else {
@@ -151,7 +152,7 @@ module.exports = function (options) {
151152
if (err) return done(null, {error: err, http$: {status: 500}});
152153
done(null, {
153154
http$: {
154-
redirect: args.redirect_uri + '?code=' + code
155+
redirect: args.redirect_uri + '?code=' + code + '&state=' + args.state
155156
}
156157
});
157158
});

profiles.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,8 @@ module.exports = function (options) {
557557
var forumProfile = _.clone(profile);
558558
forumProfile.username = forumProfile.name;
559559

560-
forumProfile.uploadedpicture = protocol + '://' + hostname + '/api/1.0/profiles/' + profile.id + '/avatar_img';
561-
forumProfile.picture = protocol + '://' + hostname + '/api/1.0/profiles/' + profile.id + '/avatar_img';
560+
forumProfile.uploadedpicture = protocol + '://' + hostname + '/api/2.0/profiles/' + profile.id + '/avatar_img';
561+
forumProfile.picture = protocol + '://' + hostname + '/api/2.0/profiles/' + profile.id + '/avatar_img';
562562

563563
seneca.act({role: 'cd-nodebb-api', cmd: 'update', user: forumProfile, id: forumProfile.userId}, function (err, res) {
564564
if (err) seneca.log.error(err);

0 commit comments

Comments
 (0)