mirror of
https://github.com/openstf/stf
synced 2025-10-03 17:59:28 +02:00
Use webpack instead of require.js for LDAP authentication.
Removing Japanese hardcoded strings (Needs gettext loading code).
This commit is contained in:
parent
15a6a1ab24
commit
c588dd87c6
15 changed files with 77 additions and 130 deletions
|
@ -1,11 +0,0 @@
|
|||
define([
|
||||
'angular'
|
||||
, './controllers/index'
|
||||
]
|
||||
, function(ng) {
|
||||
return ng.module('app', [
|
||||
'ngRoute'
|
||||
, 'app.controllers'
|
||||
])
|
||||
}
|
||||
)
|
11
res/auth/ldap/scripts/bootstrap.js
vendored
11
res/auth/ldap/scripts/bootstrap.js
vendored
|
@ -1,11 +0,0 @@
|
|||
define([
|
||||
'require'
|
||||
, 'angular'
|
||||
, 'angular-route'
|
||||
, 'app'
|
||||
, 'routes'
|
||||
]
|
||||
, function(require, ng) {
|
||||
ng.bootstrap(document, ['app'])
|
||||
}
|
||||
)
|
|
@ -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
|
||||
}
|
||||
})
|
||||
}
|
||||
}])
|
||||
})
|
|
@ -1,6 +0,0 @@
|
|||
define([
|
||||
'./SignInCtrl'
|
||||
]
|
||||
, function() {
|
||||
}
|
||||
)
|
|
@ -1,3 +0,0 @@
|
|||
define(['angular'], function(ng) {
|
||||
return ng.module('app.controllers', [])
|
||||
})
|
|
@ -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'
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
|
|
|
@ -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'
|
||||
]
|
||||
})
|
|
@ -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/'
|
||||
})
|
||||
}
|
||||
])
|
||||
})
|
10
res/auth/ldap/scripts/signin/index.js
Normal file
10
res/auth/ldap/scripts/signin/index.js
Normal 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'))
|
36
res/auth/ldap/scripts/signin/signin-controller.js
Normal file
36
res/auth/ldap/scripts/signin/signin-controller.js
Normal 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
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
|
@ -1,36 +1,30 @@
|
|||
.login2
|
||||
.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') 下記エラーを確認してください
|
||||
//span(ng-show='error.$invalid') Check errors below
|
||||
span(ng-show='error.$incorrect') ユーザー名とパスワードが間違っています
|
||||
//span(ng-show='error.$incorrect') Incorrect login details
|
||||
span(ng-show='error.$system') システム・エラー
|
||||
//span(ng-show='error.$system') System 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ユーザ名',
|
||||
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') LDAPユーザ名を入力してください
|
||||
//span(ng-show='signin.username.$error.required') Please enter your LDAP username
|
||||
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='パスワード',
|
||||
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 パスワードを入力してください
|
||||
//span Please enter your password
|
||||
span(translate) Please enter your password
|
||||
|
||||
input.btn.btn-lg.btn-primary.btn-block(type='submit', value='ログイン')
|
||||
//input.btn.btn-lg.btn-primary.btn-block(type='submit', value='Log in')
|
||||
input.btn.btn-lg.btn-primary.btn-block(type='submit', value='Log In')
|
|
@ -1,11 +1,11 @@
|
|||
doctype html
|
||||
html
|
||||
html(ng-app='app')
|
||||
head
|
||||
title STF
|
||||
base(href='/')
|
||||
meta(charset='utf-8')
|
||||
meta(name='viewport', content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui')
|
||||
include partials/styles
|
||||
body(ng-cloak)
|
||||
div(ng-view)
|
||||
script(src='static/bower_components/requirejs/require.js', data-main='static/auth/ldap/scripts/main.js')
|
||||
script(src='static/app/build/entry/commons.entry.js')
|
||||
script(src='static/app/build/entry/authldap.entry.js')
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
link(href='http://fonts.googleapis.com/css?family=Lato:100,300,400,700', media='all', rel='stylesheet', type='text/css')
|
||||
link(rel='stylesheet', href='/static/bower_components/se7en-bootstrap-3/build/stylesheets/bootstrap.min.css')
|
||||
link(rel='stylesheet', href='/static/bower_components/se7en-bootstrap-3/build/stylesheets/se7en-font.css')
|
||||
link(rel='stylesheet', href='/static/bower_components/se7en-bootstrap-3/build/stylesheets/style.css')
|
||||
link(rel='stylesheet', href='/static/bower_components/se7en-bootstrap-3/build/stylesheets/font-awesome.min.css')
|
||||
link(rel='stylesheet', href='/static/auth/ldap/styles/login.css')
|
|
@ -27,7 +27,7 @@ module.exports = {
|
|||
},
|
||||
resolve: {
|
||||
root: [
|
||||
pathutil.resource('app/components'),
|
||||
pathutil.resource('app/components')
|
||||
],
|
||||
modulesDirectories: [
|
||||
'web_modules',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue