Bug 1049943 - Reland Webmaker Login 3.0
This reverts commit f819b5fcb5
.
Conflicts:
public/js/angular/app.js
public/views/partials/user-box.html
This commit is contained in:
Родитель
5c03510769
Коммит
56b87197c5
|
@ -96,7 +96,6 @@ module.exports = function (grunt) {
|
|||
'bower_components/jquery/jquery.js',
|
||||
'bower_components/web-literacy-client/dist/web-literacy-client.with-langs.js',
|
||||
'bower_components/makeapi-client/src/make-api.js',
|
||||
'bower_components/webmaker-auth-client/dist/webmaker-auth-client.min.js',
|
||||
'bower_components/selectize/dist/js/standalone/selectize.js',
|
||||
'bower_components/webmaker-analytics/analytics.js',
|
||||
|
||||
|
@ -114,6 +113,8 @@ module.exports = function (grunt) {
|
|||
'bower_components/angular-sanitize/angular-sanitize.js',
|
||||
'bower_components/moment/min/moment+langs.min.js',
|
||||
'bower_components/angular-moment/angular-moment.min.js',
|
||||
'bower_components/webmaker-login-ux/dist/ngWebmakerLogin.js',
|
||||
'bower_components/webmaker-login-ux/dist/templates/ngWebmakerLogin.templates.js',
|
||||
|
||||
'bower_components/imagesloaded/imagesloaded.pkgd.js',
|
||||
'bower_components/masonry/dist/masonry.pkgd.js'
|
||||
|
@ -172,10 +173,12 @@ module.exports = function (grunt) {
|
|||
// For building angular js
|
||||
grunt.registerTask('build', ['uglify']);
|
||||
|
||||
grunt.registerTask('clean', ['jsbeautifier:modify']);
|
||||
|
||||
grunt.registerTask('dev', ['uglify', 'express', 'watch']);
|
||||
|
||||
// Clean & verify code (Run before commit)
|
||||
grunt.registerTask('default', ['jsbeautifier:modify', 'jshint', 'jsonlint', 'imagemin']);
|
||||
grunt.registerTask('default', ['clean', 'jshint', 'jsonlint', 'imagemin']);
|
||||
|
||||
// Verify code (Read only)
|
||||
grunt.registerTask('validate', ['jsbeautifier:verify', 'jshint', 'gettext_finder', 'jsonlint']);
|
||||
|
|
19
app.js
19
app.js
|
@ -103,6 +103,7 @@ require("./lib/makeapi")({
|
|||
var webmakerAuth = new WebmakerAuth({
|
||||
loginURL: env.get("LOGIN"),
|
||||
authLoginURL: env.get("LOGINAPI"),
|
||||
loginHost: env.get('LOGIN_EMAIL_URL'),
|
||||
secretKey: env.get("SESSION_SECRET"),
|
||||
forceSSL: env.get("FORCE_SSL"),
|
||||
domain: env.get("COOKIE_DOMAIN")
|
||||
|
@ -229,11 +230,11 @@ app.use(webmakerAuth.cookieParser());
|
|||
app.use(webmakerAuth.cookieSession());
|
||||
|
||||
// Adding an external JSON file to our existing one for the specified locale
|
||||
var authLocaleJSON = require("./bower_components/webmaker-auth-client/locale/en_US/create-user-form.json");
|
||||
var webmakerLoginJSON = require("./bower_components/webmaker-login-ux/locale/en_US/webmaker-login.json");
|
||||
var weblitLocaleJSON = require("./node_modules/web-literacy-client/dist/weblitmap.json");
|
||||
|
||||
i18n.addLocaleObject({
|
||||
"en-US": authLocaleJSON
|
||||
"en-US": webmakerLoginJSON
|
||||
}, function (err, res) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
|
@ -329,9 +330,19 @@ var middleware = require("./lib/middleware");
|
|||
|
||||
app.post('/verify', webmakerAuth.handlers.verify);
|
||||
app.post('/authenticate', webmakerAuth.handlers.authenticate);
|
||||
app.post('/create', webmakerAuth.handlers.create);
|
||||
app.post('/logout', webmakerAuth.handlers.logout);
|
||||
app.post('/check-username', webmakerAuth.handlers.exists);
|
||||
|
||||
app.post('/auth/v2/create', webmakerAuth.handlers.createUser);
|
||||
app.post('/auth/v2/uid-exists', webmakerAuth.handlers.uidExists);
|
||||
app.post('/auth/v2/request', webmakerAuth.handlers.request);
|
||||
app.post('/auth/v2/authenticateToken', webmakerAuth.handlers.authenticateToken);
|
||||
app.post('/auth/v2/verify-password', webmakerAuth.handlers.verifyPassword);
|
||||
app.post('/auth/v2/request-reset-code', webmakerAuth.handlers.requestResetCode);
|
||||
app.post('/auth/v2/reset-password', webmakerAuth.handlers.resetPassword);
|
||||
|
||||
// These webmaker-auth route handlers require a csrf token and a valid user session.
|
||||
app.post('/auth/v2/remove-password', webmakerAuth.handlers.removePassword);
|
||||
app.post('/auth/v2/enable-passwords', webmakerAuth.handlers.enablePasswords);
|
||||
|
||||
app.get("/healthcheck", routes.api.healthcheck);
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
"name": "webmaker.org",
|
||||
"version": "1.1.81",
|
||||
"dependencies": {
|
||||
"angular": "1.2.14",
|
||||
"angular-bootstrap": "0.10.0",
|
||||
"angular": "1.2.22",
|
||||
"angular-bootstrap": "0.11.1",
|
||||
"angular-resource": "1.0.7",
|
||||
"angular-route": "1.2.10",
|
||||
"angular-sanitize": "1.2.14",
|
||||
|
@ -22,9 +22,9 @@
|
|||
"text": "2.0.9",
|
||||
"web-literacy-client": "1.1.1",
|
||||
"webmaker-analytics": "0.1.3",
|
||||
"webmaker-auth-client": "0.1.14",
|
||||
"webmaker-i18n": "https://github.com/mozilla/node-webmaker-i18n/archive/v0.3.11.tar.gz",
|
||||
"webmaker-language-picker": "0.0.25",
|
||||
"webmaker-login-ux": "1.1.17",
|
||||
"animate.css": "~3.1.0",
|
||||
"ngScrollSpy": "1.0.2",
|
||||
"angular-moment": "0.7.1",
|
||||
|
|
3
env.dist
3
env.dist
|
@ -9,6 +9,9 @@ export EVENTS_URL="http://localhost:1981"
|
|||
# default port is 7777
|
||||
export PORT=7777
|
||||
|
||||
# Link supplied to the login server when a user requests a login.
|
||||
export LOGIN_EMAIL_URL="http://localhost:7777"
|
||||
|
||||
# Cluster options
|
||||
export RESTART=1
|
||||
export FORKS=2
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
@import "../../bower_components/webmaker-login-ux/dist/css/webmakerLogin.css";
|
||||
|
||||
/*********************************************************
|
||||
* To be merged in makerstrap
|
||||
*/
|
||||
|
@ -45,7 +47,29 @@ dd {
|
|||
* Navbar
|
||||
*/
|
||||
.navbar-btn {
|
||||
margin-right: 1em;
|
||||
margin-right: 0.7em;
|
||||
&:last-child {
|
||||
margin-right: 1em;
|
||||
}
|
||||
}
|
||||
|
||||
.btn-secondary-nav {
|
||||
color: #333;
|
||||
background: none;
|
||||
border-color: none;
|
||||
&:hover {
|
||||
background: #333;
|
||||
color: @white;
|
||||
}
|
||||
&.active {
|
||||
background-color: darken(#333, 8%);
|
||||
}
|
||||
}
|
||||
|
||||
.navbar-tertiary {
|
||||
.btn-secondary-nav {
|
||||
color: @white;
|
||||
}
|
||||
}
|
||||
|
||||
.navbar-affix-top {
|
||||
|
|
|
@ -382,5 +382,6 @@
|
|||
"Language Preference": "Language Preference",
|
||||
"Webmaker": "Webmaker",
|
||||
"Webmaker - Sign Up": "Webmaker - Sign Up",
|
||||
"Join Webmaker": "Join Webmaker",
|
||||
"user_deleted": "Your account has been deleted."
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
"time-grunt": "^0.3.1",
|
||||
"uuid": "1.4.x",
|
||||
"web-literacy-client": "1.1.1",
|
||||
"webmaker-auth": "0.1.4",
|
||||
"webmaker-auth": "1.0.1",
|
||||
"webmaker-download-locales": "0.1.3",
|
||||
"webmaker-i18n": "0.3.24",
|
||||
"webmaker-locale-mapping": "0.0.5",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
angular.module('webmakerApp', ['ngRoute', 'ui.bootstrap', 'webmakerApp.services',
|
||||
'webmakerAngular.login', 'localization', 'ngScrollSpy', 'angularMoment', 'wmMakeApiAngular'
|
||||
'ngWebmakerLogin', 'localization', 'ngScrollSpy', 'angularMoment', 'wmMakeApiAngular'
|
||||
])
|
||||
.config(['$routeProvider', '$locationProvider', 'makeApiProvider', 'CONFIG',
|
||||
function ($routeProvider, $locationProvider, makeApiProvider, CONFIG) {
|
||||
|
|
|
@ -98,17 +98,16 @@ angular
|
|||
];
|
||||
}
|
||||
])
|
||||
.controller('homeController', ['$rootScope', '$scope', 'wmNav', '$routeParams',
|
||||
function ($rootScope, $scope, wmNav, $routeParams) {
|
||||
.controller('homeController', ['$rootScope', '$scope', 'wmNav', '$routeParams', 'CONFIG',
|
||||
function ($rootScope, $scope, wmNav, $routeParams, CONFIG) {
|
||||
wmNav.page('home');
|
||||
wmNav.section('');
|
||||
$scope.userDel = $routeParams.userDel;
|
||||
|
||||
if ($routeParams.auth === 'login') {
|
||||
$rootScope.login();
|
||||
$rootScope.wmTokenLogin();
|
||||
} else if ($routeParams.auth === 'new-account') {
|
||||
// change this function when/if we move away from persona ?
|
||||
$rootScope.login();
|
||||
$rootScope.wmCreateUser();
|
||||
}
|
||||
}
|
||||
])
|
||||
|
|
|
@ -1,107 +0,0 @@
|
|||
angular
|
||||
.module('webmakerAngular.login', [])
|
||||
.factory('webmakerLoginService', ['$rootScope', '$window', 'CONFIG',
|
||||
function webmakerLoginService($rootScope, $window, CONFIG) {
|
||||
|
||||
// This is needed to apply scope changes for events that happen in
|
||||
// async callbacks.
|
||||
function apply() {
|
||||
if (!$rootScope.$$phase) {
|
||||
$rootScope.$apply();
|
||||
}
|
||||
}
|
||||
|
||||
var auth = new $window.WebmakerAuthClient({
|
||||
host: '',
|
||||
csrfToken: CONFIG.csrf,
|
||||
handleNewUserUI: false
|
||||
});
|
||||
|
||||
// Set up login/logout functions
|
||||
$rootScope.login = auth.login;
|
||||
$rootScope.logout = auth.logout;
|
||||
|
||||
// Set up user data
|
||||
$rootScope._user = {};
|
||||
|
||||
auth.on('login', function (user) {
|
||||
$rootScope._user = user;
|
||||
apply();
|
||||
|
||||
});
|
||||
|
||||
auth.on('logout', function (why) {
|
||||
$rootScope._user = {};
|
||||
apply();
|
||||
});
|
||||
|
||||
auth.on('error', function (message, xhr) {
|
||||
console.log('error', message, xhr);
|
||||
});
|
||||
|
||||
return auth;
|
||||
}
|
||||
])
|
||||
.controller('createUserController', ['$scope', '$http', '$modal', 'webmakerLoginService',
|
||||
function ($scope, $http, $modal, webmakerLoginService) {
|
||||
|
||||
webmakerLoginService.on('newuser', function (assertion) {
|
||||
$modal.open({
|
||||
templateUrl: '/views/create-user-form.html',
|
||||
controller: createUserCtrl,
|
||||
resolve: {
|
||||
assertion: function () {
|
||||
return assertion;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var createUserCtrl = function ($scope, $modalInstance, webmakerLoginService, assertion) {
|
||||
|
||||
$scope.form = {};
|
||||
$scope.user = {};
|
||||
|
||||
var usernameRegex = /^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\-]{1,20}$/;
|
||||
|
||||
$scope.checkUsername = function () {
|
||||
if (!$scope.form.user.username) {
|
||||
return;
|
||||
}
|
||||
if (!usernameRegex.test($scope.form.user.username.$viewValue)) {
|
||||
$scope.form.user.username.$setValidity('invalid', false);
|
||||
return;
|
||||
}
|
||||
$scope.form.user.username.$setValidity('invalid', true);
|
||||
$http
|
||||
.post(webmakerLoginService.urls.checkUsername, {
|
||||
username: $scope.form.user.username.$viewValue
|
||||
})
|
||||
.success(function (username) {
|
||||
$scope.form.user.username.$setValidity('taken', !username.exists);
|
||||
})
|
||||
.error(function (err) {
|
||||
$scope.form.user.username.$setValidity('taken', true);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.createUser = function () {
|
||||
$scope.submit = true;
|
||||
if ($scope.form.user.$valid && $scope.form.agree) {
|
||||
webmakerLoginService.createUser({
|
||||
assertion: assertion,
|
||||
user: $scope.user
|
||||
});
|
||||
$modalInstance.close();
|
||||
}
|
||||
};
|
||||
|
||||
$scope.cancel = function () {
|
||||
webmakerLoginService.analytics.webmakerNewUserCancelled();
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
};
|
||||
|
||||
webmakerLoginService.verify();
|
||||
}
|
||||
]);
|
|
@ -1,22 +1,23 @@
|
|||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown" ng-cloak ng-show="_user.email">
|
||||
<a class="navbar-user-info dropdown-toggle">
|
||||
<li dropdown class="dropdown" ng-cloak ng-show="_user.email">
|
||||
<a dropdown-toggle class="navbar-user-info dropdown-toggle">
|
||||
<img class="user-info-avatar" ng-src="{{_user.avatar}}"> {{ 'Hi' | i18n }} <strong>{{_user.username}}</strong>
|
||||
<span class="label label-primary" ng-show="_user.isAdmin">{{ 'admin' | i18n }}</span>
|
||||
<span class="label label-info" ng-show="!_user.isAdmin && _user.isSuperMentor">{{ 'supermentor' | i18n }}</span>
|
||||
<span class="label label-warning" ng-show="!_user.isAdmin && !_user.isSuperMentor && _user.isMentor">{{ 'mentor' | i18n }}</span>
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<ul dropdown-menu class="dropdown-menu">
|
||||
<li><a href="/{{lang}}/me"><span class="fa fa-th-large"></span> {{ 'My makes' | i18n }}</a></li>
|
||||
<li><a href="/{{lang}}/user/{{_user.username}}"><span class="fa fa-user"></span> {{ 'My Profile' | i18n }}</a></li>
|
||||
<li><a href="{{eventsUrl}}/user/{{_user.username}}"><span class="fa fa-flag"></span> {{ 'My Events' | i18n }}</a></li>
|
||||
<li><a href="{{accountSettingsUrl}}" target="_blank"><span class="fa fa-cog"></span> {{ 'My Settings' | i18n }}</a></li>
|
||||
<li class="divider"></li>
|
||||
<li><a ng-click="logout()"><span class="fa fa-sign-out"></span> {{ 'Sign out' | i18n }}</a></li>
|
||||
<li><a wm-logout href="#"><span class="fa fa-sign-out"></span> {{ 'Sign out' | i18n }}</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<button ng-cloak ng-show="!_user.email" class="btn btn-primary navbar-btn" ng-click="login()">{{'Sign in' | i18n }}</button>
|
||||
<button wm-join-webmaker wm-password-reset showcta="true" ng-cloak ng-show="!_user.email" class="btn btn-primary navbar-btn">{{ 'Join Webmaker' | i18n }}</button>
|
||||
<button wm-signin ng-cloak ng-show="!_user.email" class="btn btn-secondary-nav navbar-btn">{{'Sign in' | i18n }}</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
<h1>{{ 'Sign up for Webmaker' | i18n }}</h1>
|
||||
<p ng-bind-html="'signup_intro' | i18n"></p>
|
||||
<p>
|
||||
<button class="btn-page-info btn btn-secondary" ng-click="login()">{{ 'Create an account' | i18n }} <i class="fa fa-chevron-right fa-smaller"></i></button>
|
||||
<a href="#" ng-click="login()">{{ 'Log in' | i18n }} <i class="fa fa-chevron-right fa-smaller"></i></a>
|
||||
<button class="btn-page-info btn btn-secondary" wm-join-webmaker showcta="true">{{ 'Create an account' | i18n }} <i class="fa fa-chevron-right fa-smaller"></i></button>
|
||||
<a href="#" wm-signin>{{ 'Log in' | i18n }} <i class="fa fa-chevron-right fa-smaller"></i></a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -42,8 +42,6 @@
|
|||
</head>
|
||||
<body id="{{currentPageId}}">
|
||||
|
||||
<div ng-controller="createUserController"></div>
|
||||
|
||||
<header class="explore-nav" ng-include="'/views/partials/navigation.html'" ng-controller="navigationController"></header>
|
||||
<div id="locale-banner" ng-controller="localebannerController" ng-hide="bannerBool">
|
||||
<div class="container">
|
||||
|
|
Загрузка…
Ссылка в новой задаче