diff --git a/modules/core/server/controllers/errors.server.controller.js b/modules/core/server/controllers/errors.server.controller.js index db81a8ec86..935a9299d4 100644 --- a/modules/core/server/controllers/errors.server.controller.js +++ b/modules/core/server/controllers/errors.server.controller.js @@ -8,10 +8,10 @@ var getUniqueErrorMessage = function(err) { try { var fieldName = err.err.substring(err.err.lastIndexOf('.$') + 2, err.err.lastIndexOf('_1')); - output = fieldName.charAt(0).toUpperCase() + fieldName.slice(1) + ' already exist'; + output = fieldName.charAt(0).toUpperCase() + fieldName.slice(1) + ' already exists'; } catch(ex) { - output = 'Unique field already exist'; + output = 'Unique field already exists'; } return output; diff --git a/modules/users/client/config/users.client.routes.js b/modules/users/client/config/users.client.routes.js index 9b0546360e..4c00bc0651 100644 --- a/modules/users/client/config/users.client.routes.js +++ b/modules/users/client/config/users.client.routes.js @@ -36,7 +36,7 @@ angular.module('users').config(['$stateProvider', templateUrl: 'modules/users/views/authentication/signup.client.view.html' }). state('authentication.signin', { - url: '/signin', + url: '/signin?err', templateUrl: 'modules/users/views/authentication/signin.client.view.html' }). state('password', { diff --git a/modules/users/client/controllers/authentication.client.controller.js b/modules/users/client/controllers/authentication.client.controller.js index a1b349f4f1..fed9225718 100644 --- a/modules/users/client/controllers/authentication.client.controller.js +++ b/modules/users/client/controllers/authentication.client.controller.js @@ -4,6 +4,9 @@ angular.module('users').controller('AuthenticationController', ['$scope', '$http function($scope, $http, $location, Authentication) { $scope.authentication = Authentication; + // Get an eventual error defined in the URL query string: + $scope.error = $location.search().err; + // If user is signed in then redirect back home if ($scope.authentication.user) $location.path('/'); diff --git a/modules/users/client/views/authentication/signin.client.view.html b/modules/users/client/views/authentication/signin.client.view.html index 5345a5dc6c..0d78a1391f 100644 --- a/modules/users/client/views/authentication/signin.client.view.html +++ b/modules/users/client/views/authentication/signin.client.view.html @@ -18,12 +18,12 @@

Or with your account

  or  Sign up -
+
Forgot your password?
-
- -
+ + +
diff --git a/modules/users/server/controllers/users/users.authentication.server.controller.js b/modules/users/server/controllers/users/users.authentication.server.controller.js index d2c5acd27c..ea4c9e5e14 100644 --- a/modules/users/server/controllers/users/users.authentication.server.controller.js +++ b/modules/users/server/controllers/users/users.authentication.server.controller.js @@ -83,12 +83,15 @@ exports.signout = function (req, res) { exports.oauthCallback = function (strategy) { return function (req, res, next) { passport.authenticate(strategy, function (err, user, redirectURL) { - if (err || !user) { - return res.redirect('/#!/signin'); + if (err) { + return res.redirect('/authentication/signin?err=' + encodeURIComponent(errorHandler.getErrorMessage(err))); + } + if (!user) { + return res.redirect('/authentication/signin'); } req.login(user, function (err) { if (err) { - return res.redirect('/#!/signin'); + return res.redirect('/authentication/signin'); } return res.redirect(redirectURL || '/'); diff --git a/modules/users/server/models/user.server.model.js b/modules/users/server/models/user.server.model.js index 3f2225e6f1..4ffd1f1738 100644 --- a/modules/users/server/models/user.server.model.js +++ b/modules/users/server/models/user.server.model.js @@ -52,6 +52,7 @@ var UserSchema = new Schema({ email: { type: String, trim: true, + unique: true, default: '', validate: [validateLocalStrategyEmail, 'Please fill a valid email address'] },