1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-05 10:39:25 +02:00
OpenSTF/res/auth/mock/scripts/signin/signin-controller.js
Gunther Brunner 97ba9a2ec0 Use webpack instead of require.js for MOCK authentication.
Removing Japanese hardcoded strings (Needs gettext loading code).
2015-06-30 20:06:38 +09:00

36 lines
878 B
JavaScript

module.exports = function SignInCtrl($scope, $http) {
$scope.error = null
$scope.submit = function () {
var data = {
username: $scope.signin.username.$modelValue
, email: $scope.signin.email.$modelValue
}
$scope.invalid = false
$http.post('/auth/api/v1/mock', 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
}
})
}
}