diff --git a/Gruntfile.coffee b/Gruntfile.coffee
index 249c81e..7f4b0e1 100644
--- a/Gruntfile.coffee
+++ b/Gruntfile.coffee
@@ -16,6 +16,8 @@ module.exports = (grunt) ->
'app/_bower_components/locompleter/locompleter.js'
'app/_bower_components/webmaker-analytics/analytics.js'
'app/_bower_components/spiiin/src/spiiin.js'
+ 'app/_bower_components/webmaker-login-ux/dist/ngWebmakerLogin.js'
+ 'app/_bower_components/webmaker-login-ux/dist/templates/ngWebmakerLogin.templates.js'
'app/_js/app.js'
'app/_js/services.js'
'app/_js/controllers.js'
diff --git a/app/_js/app.js b/app/_js/app.js
index bc02965..752cac7 100644
--- a/app/_js/app.js
+++ b/app/_js/app.js
@@ -4,6 +4,7 @@ angular.module('wmProfile', [
'ui.bootstrap',
'wmProfile.filters',
'wmProfile.services',
+ 'ngWebmakerLogin',
'localization',
'wmProfile.directives',
'wmProfile.controllers',
@@ -14,9 +15,9 @@ angular.module('wmProfile', [
config(['$routeProvider', '$locationProvider',
function ($routeProvider, $locationProvider) {
$routeProvider.when('/:locale?/user/:username/badges', {
- templateUrl: '/user/_partials/badges.html',
- controller: 'badges'
- })
+ templateUrl: '/user/_partials/badges.html',
+ controller: 'badges'
+ })
.when('/:locale?/user/:username/badges', {
templateUrl: '/user/_partials/badges.html',
controller: 'badges'
@@ -58,10 +59,10 @@ run(['$rootScope', '$http', 'jQuery',
};
$.ajax({
- async: false,
- url: '/user/_service/env.json',
- dataType: 'json'
- })
+ async: false,
+ url: '/user/_service/env.json',
+ dataType: 'json'
+ })
.done(function (config) {
$rootScope.WMP.config = config;
// Set locale information
diff --git a/app/_js/controllers.js b/app/_js/controllers.js
index d2e9ea9..32254ec 100644
--- a/app/_js/controllers.js
+++ b/app/_js/controllers.js
@@ -99,71 +99,4 @@ angular.module('wmProfile.controllers', [])
return curYear !== prevYear;
};
}
- ])
- .controller('createUserController', ['$scope', '$http', '$modal', 'loginService',
- function ($scope, $http, $modal, loginService) {
-
- loginService.auth.on('newuser', function (assertion) {
- $modal.open({
- templateUrl: '/user/_partials/create-user-form.html',
- controller: createUserCtrl,
- resolve: {
- assertion: function () {
- return assertion;
- }
- }
- });
- });
-
- var createUserCtrl = function ($scope, $modalInstance, loginService, assertion) {
-
- $scope.form = {};
- $scope.user = {};
-
- // TODO: Finish localization and remove hard coded variables.
- $scope.supported_languages = 'en-US';
- $scope.currentLang = 'en-US';
- $scope.langmap = {
- 'en-US': {
- 'nativeName': 'English (United States)',
- 'englishName': 'English (United States)'
- }
- };
-
- $scope.checkUsername = function () {
- if (!$scope.form.user.username) {
- return;
- }
- $http
- .post(loginService.auth.urls.checkUsername, {
- username: $scope.form.user.username.$viewValue
- })
- .success(function (username) {
- $scope.form.user.username.$setValidity('taken', !username.exists);
- })
- .error(function (err) {
- console.log(err);
- $scope.form.user.username.$setValidity('taken', true);
- });
- };
-
- $scope.createUser = function () {
- $scope.submit = true;
- if ($scope.form.user.$valid && $scope.form.agree) {
- loginService.auth.createUser({
- assertion: assertion,
- user: $scope.user
- });
- $modalInstance.close();
- }
- };
-
- $scope.cancel = function () {
- loginService.auth.analytics.webmakerNewUserCancelled();
- $modalInstance.dismiss('cancel');
- };
- };
-
- loginService.auth.verify();
- }
]);
diff --git a/app/_js/directives.js b/app/_js/directives.js
index 2ae8c43..b9112da 100644
--- a/app/_js/directives.js
+++ b/app/_js/directives.js
@@ -12,59 +12,57 @@ angular.module('wmProfile.directives', [])
}
};
})
- .directive('wmpSrc', ['jQuery', function (jQuery) {
- // Add wmp-src to an img to only give it a src if the target is loadable
- // This prevents broken images from displaying and creates hooks for other display logic
- return {
- restrict: 'A',
- scope: {
- url: '@wmpSrc',
- didFail: '=wmpSrcFailed'
- },
- link: function ($scope, el, attrs) {
- var elLoader = jQuery('');
- el.fadeTo(0, 0);
-
- elLoader.on('load', function () {
- el.attr('src', $scope.url).fadeTo(200, 1);
- $scope.didFail = false;
- $scope.$apply();
- });
+ .directive('wmpSrc', ['jQuery',
+ function (jQuery) {
+ // Add wmp-src to an img to only give it a src if the target is loadable
+ // This prevents broken images from displaying and creates hooks for other display logic
+ return {
+ restrict: 'A',
+ scope: {
+ url: '@wmpSrc',
+ didFail: '=wmpSrcFailed'
+ },
+ link: function ($scope, el, attrs) {
+ var elLoader = jQuery('
');
+ el.fadeTo(0, 0);
- elLoader.on('error', function () {
- $scope.didFail = true;
- $scope.$apply();
- });
+ elLoader.on('load', function () {
+ el.attr('src', $scope.url).fadeTo(200, 1);
+ $scope.didFail = false;
+ $scope.$apply();
+ });
- // Attempt to load target image in a non attached IMG element
- elLoader.attr('src', $scope.url);
- }
- };
- }])
- .directive('wmpLogin', ['WebmakerAuthClient', 'loginService',
- function (WebmakerAuthClient, loginService) {
+ elLoader.on('error', function () {
+ $scope.didFail = true;
+ $scope.$apply();
+ });
+
+ // Attempt to load target image in a non attached IMG element
+ elLoader.attr('src', $scope.url);
+ }
+ };
+ }
+ ])
+ .directive('wmpLogin', ['$rootScope',
+ function ($rootScope) {
return {
restrict: 'E',
scope: false,
templateUrl: '/user/_partials/login.html',
link: function ($scope, el, attrs) {
- $scope.userInfo = loginService.getData();
- $scope.userLoggedIn = !!$scope.userInfo; // No user info means not logged in
+ $scope.userInfo = undefined;
+ $scope.userLoggedIn = false; // No user info means not logged in
- $scope.$on('userLoggedIn', function (event, data) {
+ $rootScope.$on('signedIn', function (user) {
$scope.userLoggedIn = true;
- $scope.userInfo = data;
+ $scope.userInfo = user;
$scope.$digest();
});
- $scope.$on('userLoggedOut', function (event, data) {
+ $rootScope.$on('loggedOut', function (user) {
$scope.userLoggedIn = false;
$scope.userInfo = undefined;
- $scope.$digest();
});
-
- $scope.login = loginService.auth.login;
- $scope.logout = loginService.auth.logout;
}
};
}
diff --git a/app/_less/components/imports.less b/app/_less/components/imports.less
index ec41173..3389af7 100644
--- a/app/_less/components/imports.less
+++ b/app/_less/components/imports.less
@@ -12,3 +12,6 @@
// Selectize for create user form.
@import "../_bower_components/selectize/dist/less/selectize";
+
+// Webmaker Login
+@import "../_bower_components/webmaker-login-ux/dist/css/webmakerLogin.css";
diff --git a/app/_partials/login.html b/app/_partials/login.html
index fe621b4..a6f39c0 100644
--- a/app/_partials/login.html
+++ b/app/_partials/login.html
@@ -1,25 +1,25 @@