Files
stf/res/auth/mock/scripts/controllers/SignInCtrl.js
Gunther Brunner e87dc45fb9 - e2e tests should work with production now also by exporting STF_URL, STF_USERNAME and STF_PASSWORD.
- Added BrowerLogs, a Protractor helper which redirects browser logs to the console, with an additional expectNoLogs option.
- Refactored Login model names to work seamlessly.
2014-08-26 20:57:26 +09:00

38 lines
999 B
JavaScript

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