Use webpack instead of require.js for LDAP authentication.

Removing Japanese hardcoded strings (Needs gettext loading code).
This commit is contained in:
Gunther Brunner
2015-06-30 19:44:04 +09:00
parent 15a6a1ab24
commit c588dd87c6
15 changed files with 77 additions and 130 deletions

View File

@@ -1,11 +0,0 @@
define([
'angular'
, './controllers/index'
]
, function(ng) {
return ng.module('app', [
'ngRoute'
, 'app.controllers'
])
}
)

View File

@@ -1,11 +0,0 @@
define([
'require'
, 'angular'
, 'angular-route'
, 'app'
, 'routes'
]
, function(require, ng) {
ng.bootstrap(document, ['app'])
}
)

View File

@@ -1,37 +0,0 @@
define(['./module'], function(mod) {
mod.controller('SignInCtrl', ['$scope', '$http', function($scope, $http) {
$scope.error = null
$scope.submit = function() {
var data = {
username: $scope.signin.username.$modelValue
, password: $scope.signin.password.$modelValue
}
$scope.invalid = false
$http.post('/auth/api/v1/ldap', data)
.success(function(response) {
$scope.error = null
location.replace(response.redirect)
})
.error(function(response) {
switch (response.error) {
case 'ValidationError':
$scope.error = {
$invalid: true
}
break
case 'InvalidCredentialsError':
$scope.error = {
$incorrect: true
}
break
default:
$scope.error = {
$server: true
}
break
}
})
}
}])
})

View File

@@ -1,6 +0,0 @@
define([
'./SignInCtrl'
]
, function() {
}
)

View File

@@ -1,3 +0,0 @@
define(['angular'], function(ng) {
return ng.module('app.controllers', [])
})

View File

@@ -1,5 +1,22 @@
require.ensure(['angular', 'angular-route'], function (require) {
require.ensure([], function (require) {
require('nine-bootstrap')
require('angular')
require('angular-route')
require('angular-touch')
angular.module('app', [
'ngRoute',
'ngTouch',
require('gettext').name,
require('./signin').name
])
.config(function ($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true)
$routeProvider
.otherwise({
redirectTo: '/auth/ldap'
})
})
})

View File

@@ -1,19 +0,0 @@
require.config({
paths: {
'angular': '../../../bower_components/angular/angular'
, 'angular-route': '../../../bower_components/angular-route/angular-route'
}
, shim: {
'angular': {
exports: 'angular'
}
, 'angular-route': {
deps: [
'angular'
]
}
}
, deps: [
'./bootstrap'
]
})

View File

@@ -1,17 +0,0 @@
define(['./app'], function(app) {
return app.config([
'$routeProvider'
, '$locationProvider'
, function($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true)
$routeProvider
.when('/auth/ldap/', {
templateUrl: '/static/auth/ldap/views/partials/signin.html'
, controller: 'SignInCtrl'
})
.otherwise({
redirectTo: '/auth/ldap/'
})
}
])
})

View File

@@ -0,0 +1,10 @@
require('./signin.css')
module.exports = angular.module('stf.signin', [])
.config(function ($routeProvider) {
$routeProvider
.when('/auth/ldap/', {
template: require('./signin.jade')
})
})
.controller('SignInCtrl', require('./signin-controller'))

View File

@@ -0,0 +1,36 @@
module.exports = function SignInCtrl($scope, $http) {
$scope.error = null
$scope.submit = function () {
var data = {
username: $scope.signin.username.$modelValue
, password: $scope.signin.password.$modelValue
}
$scope.invalid = false
$http.post('/auth/api/v1/ldap', data)
.success(function (response) {
$scope.error = null
location.replace(response.redirect)
})
.error(function (response) {
switch (response.error) {
case 'ValidationError':
$scope.error = {
$invalid: true
}
break
case 'InvalidCredentialsError':
$scope.error = {
$incorrect: true
}
break
default:
$scope.error = {
$server: true
}
break
}
})
}
}

View File

@@ -0,0 +1,79 @@
body {
background: #eeeeee;
}
.login2 {
padding: 15px;
background: #eeeeee;
}
.login2 .login-wrapper {
max-width: 420px;
margin: 0 auto;
text-align: center;
}
.login2 .login-wrapper img {
margin: 40px auto;
}
.login2 .login-wrapper .input-group-addon {
padding: 8px 0;
background: #f4f4f4;
min-width: 48px;
text-align: center;
}
.login2 .login-wrapper .input-group-addon i.falock {
font-size: 18px;
}
.login2 .login-wrapper input.form-control {
height: 48px;
font-size: 15px;
box-shadow: none;
}
.login2 .login-wrapper .checkbox {
margin-bottom: 30px;
}
.login2 .login-wrapper input[type="submit"] {
padding: 10px 0 12px;
margin: 20px 0 30px;
}
.login2 .login-wrapper input[type="submit"]:hover {
background: transparent;
}
.login2 .login-wrapper .social-login {
margin-bottom: 20px;
padding-bottom: 25px;
border-bottom: 1px solid #cccccc;
}
.login2 .login-wrapper .social-login > .btn {
width: 49%;
margin: 0;
}
.login2 .login-wrapper .social-login .facebook {
background-color: #335397;
border-color: #335397;
}
.login2 .login-wrapper .social-login .facebook:hover {
background-color: transparent;
color: #335397;
}
.login2 .login-wrapper .social-login .twitter {
background-color: #00c7f7;
border-color: #00c7f7;
}
.login2 .login-wrapper .social-login .twitter:hover {
background-color: transparent;
color: #00c7f7;
}

View File

@@ -0,0 +1,30 @@
.login2(ng-controller='SignInCtrl')
.login-wrapper
a(href='./')
img(width='160', height='160', src='/static/logo/exports/STF-512.png', title='STF')
form(name='signin', novalidate, ng-submit='submit()')
.alert.alert-danger(ng-show='error')
span(ng-show='error.$invalid', translate) Check errors below
span(ng-show='error.$incorrect', translate) Incorrect login details
span(ng-show='error.$server', translate) Server error. Check log output.
.form-group
.input-group
span.input-group-addon
i.fa.fa-user
input.form-control(ng-model='username', name='username', required, type='text', placeholder='LDAP Username',
autocorrect='off', autocapitalize='off', spellcheck='false', autocomplete='section-login username')
.alert.alert-warning(ng-show='signin.username.$dirty && signin.username.$invalid')
span(ng-show='signin.username.$error.required', translate) Please enter your LDAP username
.form-group
.input-group
span.input-group-addon
i.fa.fa-lock
input.form-control(ng-model='password', name='password', required, type='password', placeholder='Password',
autocorrect='off', autocapitalize='off', spellcheck='false', autocomplete='section-login current-password')
.alert.alert-warning(ng-show='signin.password.$dirty && signin.password.$invalid')
span(translate) Please enter your password
input.btn.btn-lg.btn-primary.btn-block(type='submit', value='Log In')