Skip to content

Commit f06ea87

Browse files
committed
Improve passport integration (almost works now ;)
1 parent 0541a19 commit f06ea87

3 files changed

Lines changed: 14 additions & 13 deletions

File tree

client/app/modules/users/controllers/login.ctrl.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Contrller for Login Page
1010
**/
1111
angular.module('com.module.users')
12-
.controller('LoginCtrl', function ($scope, $routeParams, $location, toasty, User, AppAuth, AuthProvider, gettextCatalog) {
12+
.controller('LoginCtrl', function ($scope, $routeParams, $location, toasty, User, AppAuth, AuthProvider, ENV, gettextCatalog) {
1313

1414
var TWO_WEEKS = 1000 * 60 * 60 * 24 * 7 * 2;
1515

@@ -60,7 +60,7 @@ angular.module('com.module.users')
6060
};
6161

6262
$scope.socialLogin = function (provider) {
63-
window.location = provider.authPath;
63+
window.location = ENV.siteUrl + provider.authPath;
6464
};
6565

6666
AuthProvider.count(function (result) {

client/app/modules/users/controllers/users.ctrl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ app.controller('UsersCtrl', function ($scope, $stateParams, $state, User, toasty
1010
where: {
1111
id: $stateParams.id
1212
},
13-
include: ['roles']
13+
include: ['roles', 'identities', 'credentials', 'accessTokens']
1414
}
1515
}, function (result) {
1616
$scope.user = result;

server/boot/passport.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,19 @@ module.exports = function (app) {
8888

8989
var ensureLoggedIn = require('connect-ensure-login').ensureLoggedIn;
9090

91-
app.get('/auth/account', ensureLoggedIn('/login.html'), function (req, res, next) {
92-
res.render('pages/loginProfiles', {
93-
user: req.user,
94-
url: req.url
95-
});
91+
app.get('/auth/account', ensureLoggedIn('/'), function(req, res, next) {
92+
console.log('Logged in', req.user)
93+
res.redirect('/#/app');
9694
});
9795

98-
app.get('/link/account', ensureLoggedIn('/login.html'), function (req, res, next) {
99-
res.render('pages/linkedAccounts', {
100-
user: req.user,
101-
url: req.url
102-
});
96+
app.get('/auth/current', function(req, res, next) {
97+
if (!req.isAuthenticated || !req.isAuthenticated()) {
98+
return res.status(200).json({});
99+
}
100+
//poor man's copy
101+
var ret = JSON.parse(JSON.stringify(req.user));
102+
delete ret.password;
103+
res.status(200).json(ret);
103104
});
104105

105106
app.get('/auth/logout', function (req, res, next) {

0 commit comments

Comments
 (0)