Add error checking, add method handler for login

This commit is contained in:
manzerbredes 2016-02-04 13:20:45 +01:00
parent 37e02d62c4
commit 784b25754c
5 changed files with 53 additions and 31 deletions

View file

@ -73,6 +73,7 @@
<!-- Include resquest dependencies --> <!-- Include resquest dependencies -->
<script src="./js/requests/identity.js"></script> <script src="./js/requests/identity.js"></script>
<script src="./js/requests/errors.js"></script>
<!-- Include controller --> <!-- Include controller -->
<script src="./js/controllers/login.js"></script> <script src="./js/controllers/login.js"></script>

View file

@ -1,8 +1,3 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/** /**
* Represents a book. * Represents a book.
@ -10,30 +5,37 @@
*/ */
mainApp.controller('loginCtrl', function ($scope,$interval,$sce) mainApp.controller('loginCtrl', function ($scope,$interval,$sce)
{ {
// Define default states // Define default states
$('#loginModal').modal({backdrop: 'static', keyboard: false}); $('#loginModal').modal({backdrop: 'static', keyboard: false});
$('#loadingLoginButton').hide(); $('#loadingLoginButton').hide();
$('#failedToLoginAlert').hide(); $('#failedToLoginAlert').hide();
$('#loginButton').click(function(){ $('#loginButton').click(function(){
$('#loginButton').hide(); $('#loginButton').hide();
$('#loadingLoginButton').show(); $('#loadingLoginButton').show();
$('#failedToLoginAlert').hide(); $('#failedToLoginAlert').hide();
var result=identity.login($("#loginFormUsername").val(), $("#loginFormProjectname").val(), $("#loginFormPassword").val());
$interval(
function()
{
$('#failedToLoginAlert').show();
$interval(
function()
{
// Check for error
if(!errors.checkForLogin(result)){
$('#failedToLoginAlert').show();
}
else {
$('#loginModal').modal('hide');
}
// Reset button state
$('#loginButton').show(); $('#loginButton').show();
$('#loadingLoginButton').hide(); $('#loadingLoginButton').hide();
}, 2000,1);
}, 2000,1);
}); });
}) });

View file

@ -0,0 +1,14 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
var errors={};
errors.checkForLogin=function(result){
// TODO
return true;
};

View file

@ -1,9 +1,14 @@
// Make Namespace // Make Namespace
var identity = {} ; var identity = {};
identity.login=function(username, projectname, password){
// Todo
return "tokens";
};

View file

@ -12,18 +12,18 @@
<div class="modal-body"> <div class="modal-body">
<div class="form-group"> <div class="form-group">
<label label-default="" for="inputUser">User</label> <label label-default="" for="loginFormUsername">User</label>
<input class="form-control" id="inputUser" <input class="form-control" id="loginFormUsername"
placeholder="Email" type="text" ng-model="identityFormData.user"> placeholder="Email" type="text" ng-model="identityFormData.user">
</div> </div>
<div class="form-group"> <div class="form-group">
<label label-default="" for="inputProject">Project</label> <label label-default="" for="loginFormProjectname">Project</label>
<input class="form-control" id="inputProject" <input class="form-control" id="loginFormProjectname"
placeholder="Project Name" type="password" ng-model="identityFormData.project"> placeholder="Project Name" type="password" ng-model="identityFormData.project">
</div> </div>
<div class="form-group"> <div class="form-group">
<label label-default="" for="inputPassword">Password</label> <label label-default="" for="loginFormPassword">Password</label>
<input class="form-control" id="inputPassword" <input class="form-control" id="loginFormPassword"
placeholder="Password" type="password" ng-model="identityFormData.password"> placeholder="Password" type="password" ng-model="identityFormData.password">
</div> </div>