-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
half working register. need to fix GET
- Loading branch information
Showing
9 changed files
with
260 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<div class="RegisterWrapper" style="text-align:center;" ng-controller="RegisterController"> | ||
<div> <h1> REGISTER </h1> </div> | ||
<div class="username" style=""> | ||
<div class="form-group"> | ||
<label for="usernameInput">Username</label> | ||
<input class="form-control input-sm" ng-model="regUser" type="text" style="margin: 0 auto; width: 50%;"> | ||
</div> | ||
</div> | ||
|
||
<div class="password"> | ||
<div class="form-group"> | ||
<label for="passwordInput">Password</label> | ||
<input class="form-control input-sm" ng-model="regPass" type="text" style="margin: 0 auto; width: 50%;"> | ||
</div> | ||
</div> | ||
|
||
<div class="fname"> | ||
<div class="form-group"> | ||
<label for="fnameInput">First Name</label> | ||
<input class="form-control input-sm" ng-model="regName" type="text" style="margin: 0 auto; width: 50%;"> | ||
</div> | ||
</div> | ||
|
||
<div class="lname"> | ||
<div class="form-group"> | ||
<label for="lnameInput">Last Name</label> | ||
<input class="form-control input-sm" ng-model="regLast" type="text" style="margin: 0 auto; width: 50%;"> | ||
</div> | ||
</div> | ||
|
||
<div class="addr"> | ||
<div class="form-group"> | ||
<label for="addrInput">Address</label> | ||
<input class="form-control input-sm" ng-model="regAddr" type="text" style="margin: 0 auto; width: 50%;"> | ||
</div> | ||
</div> | ||
|
||
<div class="email"> | ||
<div class="form-group"> | ||
<label for="emailInput">Email</label> | ||
<input class="form-control input-sm" ng-model="regMail" type="text" style="margin: 0 auto; width: 50%;"> | ||
</div> | ||
</div> | ||
|
||
<div class="phone"> | ||
<div class="form-group"> | ||
<label for="phoneInput">Phone</label> | ||
<input class="form-control input-sm" ng-model="regPhone" type="text" style="margin: 0 auto; width: 50%;"> | ||
</div> | ||
</div> | ||
<button type="button" class="btn btn-default" ng-click="registerUsr()" style="display: block; margin: 0 auto; margin-top: 20px;">REGISTER</button> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
angular.module("myApp.register", ["ngRoute", "myApp.register.registerHandler"]) | ||
|
||
.config(["$routeProvider", function($routeProvider) { | ||
$routeProvider.when("/register", { | ||
templateUrl: "register/register.html", | ||
controller: "RegisterController" | ||
}); | ||
}]) | ||
|
||
.controller("RegisterController", function($scope, $location, registerHandler) { | ||
$scope.registerUsr = function() { | ||
|
||
if($scope.regUser || $scope.regMail) { | ||
registerHandler.check($scope.regUser, $scope.regMail, function (result) { | ||
|
||
if(result.success){ | ||
registerHandler.register($scope.regUser, $scope.regPass, $scope.regName, $scope.regLast, $scope.regAddr, $scope.regMail, $scope.regPhone, | ||
function(result) { | ||
if(result.success){ | ||
$location.url("/login"); | ||
}else{ | ||
alert("Error2"); | ||
} | ||
}); | ||
}else{ | ||
alert("Error1"); | ||
} | ||
}); | ||
|
||
} else { | ||
alert("Username and Email fields cannot be empty"); | ||
} | ||
} | ||
|
||
// registerHandler.check($scope.regUser, $scope.regMail, function (result) { | ||
// if(result.success){ | ||
// registerHandler.register($scope.regUser, $scope.regPass, $scope.regName $scope.regLast, $scope.regAddr, $scope.regMail, $scope.regPhone, | ||
// function(result) { | ||
// if(result.success){ | ||
// $location.url("/login"); | ||
// }else{ | ||
// alert("Error2"); | ||
// } | ||
// }); | ||
// }; | ||
// }; | ||
// }else{ | ||
// alert("Error1"); | ||
// } | ||
// }); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
var SERVICE_BASE_URL = 'http://localhost:8080/'; | ||
|
||
angular.module("myApp.register.registerHandler", []) | ||
.service("registerHandler", function($http, $q) { | ||
this.register = function (username, password, fname, lname, addr, email, phone, callback) { | ||
var $regpost = $http({ | ||
method: 'POST', | ||
url: SERVICE_BASE_URL + "register", | ||
headers: {'Content-Type': 'application/x-www-form-urlencoded'}, | ||
transformRequest: function(obj) { | ||
var str = []; | ||
for(var p in obj) | ||
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); | ||
return str.join("&"); | ||
}, | ||
data: {userName: username, password: password, fname: fname, | ||
lname: lname, addr: addr, email: email, phone: phone} | ||
}).success(function (result) { | ||
return callback(result); | ||
}).error(function (result) { | ||
return callback(result); | ||
}); | ||
}; | ||
|
||
this.check = function(username, email, callback) { | ||
var $checkpost = $http({ | ||
method: 'GET', | ||
url: SERVICE_BASE_URL + "register", | ||
headers: {'Content-Type': 'application/x-www-form-urlencoded'}, | ||
transformRequest: function(obj) { | ||
var str = []; | ||
for(var p in obj) | ||
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); | ||
return str.join("&"); | ||
}, | ||
data: {userName: username, email: email} | ||
}).success(function (result) { | ||
return callback(result); | ||
}).error(function (result) { | ||
return callback(result); | ||
}); | ||
|
||
}; | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
module.exports = { | ||
user: "jwoo", | ||
password: "", //Put password here (I'll message you my password :P) | ||
connectString: "" | ||
connectString: "localhost:1525/CRS" | ||
//if WFH then localhost:1525/CRS | ||
//if lab machine then CRS | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters