Skip to content

Commit 2be9ec3

Browse files
committed
sign in files and view
adding files for sign in features and the view
1 parent 4253be0 commit 2be9ec3

File tree

4 files changed

+105
-0
lines changed

4 files changed

+105
-0
lines changed

Diff for: Zenergy/Zenergy/Controllers/RegisterController.cs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Web;
5+
using System.Web.Mvc;
6+
7+
namespace Zenergy.Controllers
8+
{
9+
public class RegisterController : Controller
10+
{
11+
public ActionResult Index()
12+
{
13+
return View();
14+
}
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
zenergyApp.controller("registrationPageController", ["$scope", "$http", "$httpParamSerializerJQLike", "tokenService", "$window", function ($scope, $http, $httpParamSerializerJQLike, tokenService, $window) {
2+
3+
$scope.user = { mail: '', password: '' };
4+
$scope.hasError = false;
5+
$scope.connexion = function () {
6+
var response = $http({
7+
url: 'api/login',
8+
method: 'POST',
9+
data: $httpParamSerializerJQLike({ grant_type: 'password', username: $scope.user.mail, password: $scope.user.password }),
10+
//data: $httpParamSerializerJQLike({ grant_type: 'password', username: $scope.user.mail, password: CryptoJS.MD5($scope.user.password).toString() }),
11+
headers: {
12+
'Content-Type': 'application/x-www-form-urlencoded'
13+
}
14+
}).then(function successCallback(response) {
15+
$scope.hasError = false;
16+
tokenService.saveToken(response.data.access_token, response.data.userName);
17+
window.location.replace("/Home");
18+
}, function errorCallback(response) {
19+
$scope.hasError = true;
20+
tokenService.deleteToken();
21+
$scope.user.mail = '';
22+
$scope.user.password = '';
23+
});
24+
25+
};
26+
}]);

Diff for: Zenergy/Zenergy/Views/Register/index.cshtml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
2+
@{
3+
ViewBag.Title = "index";
4+
}
5+
6+
<h2>Registration</h2>
7+
<div class="container " ng-controller="loginPageController">
8+
<div class="row">
9+
<div class="col-md-3 col-lg-offset-4">
10+
<h1>Sign in</h1>
11+
<form ng-submit="signIn()">
12+
13+
<div class="form-group" ng-class="{ 'has-error': hasError}">
14+
<input type="email" class="form-control" ng-model="user.mail" placeholder="Email">
15+
</div>
16+
17+
<div class="form-group" ng-class="{ 'has-error': hasError}">
18+
<input type="password" class="form-control" ng-model="user.password" placeholder="Password">
19+
</div>
20+
21+
<div class="form-group" ng-class="{ 'has-error': hasError}">
22+
<input type="password" class="form-control" ng-model="user.passwordBis" placeholder="Password Confirmation">
23+
</div>
24+
25+
<div class="form-group">
26+
<input type="text" class="form-control" ng-model="user.firstName" placeholder="Firstname">
27+
</div>
28+
29+
<div class="form-group">
30+
<input type="text" class="form-control" ng-model="user.lastName" placeholder="Lastname">
31+
</div>
32+
33+
<div class="form-group">
34+
<input type="text" class="form-control" ng-model="user.adr1" placeholder="Adress">
35+
</div>
36+
37+
<div class="form-group">
38+
<input type="text" class="form-control" ng-model="user.adr2" placeholder="Rest of the adress ">
39+
</div>
40+
41+
<div class="form-group">
42+
<input type="text" class="form-control" ng-model="user.pc" placeholder="Postal Code ">
43+
</div>
44+
45+
<div class="form-group">
46+
<input type="text" class="form-control" ng-model="user.town" placeholder="Town ">
47+
</div>
48+
49+
<div class="form-group">
50+
<input type="text" class="form-control" ng-model="user.phone" placeholder="Phone ">
51+
</div>
52+
53+
<p class="text-danger" ng-if="hasError">Invalid email or password</p>
54+
<input type="submit" id="submit" value="Sign in" class="btn btn-primary" />
55+
</form>
56+
</div>
57+
</div>
58+
</div>
59+
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/md5.js"></script>
60+

Diff for: Zenergy/Zenergy/Zenergy.csproj

+3
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@
174174
<ItemGroup>
175175
<Compile Include="Controllers\ApiControllers\usersController.cs" />
176176
<Compile Include="Controllers\LoginController.cs" />
177+
<Compile Include="Controllers\RegisterController.cs" />
177178
<Compile Include="Models\accessory.cs">
178179
<DependentUpon>ZenergyModel.tt</DependentUpon>
179180
</Compile>
@@ -301,6 +302,7 @@
301302
<Content Include="Scripts\Controllers\homePageController.js" />
302303
<Content Include="Scripts\Controllers\loginPageController.js" />
303304
<Content Include="Scripts\Controllers\mainController.js" />
305+
<Content Include="Scripts\Controllers\registerPageController.js" />
304306
<Content Include="Scripts\Factories\authInterceptorService.js" />
305307
<Content Include="Scripts\Factories\tokenService.js" />
306308
<Content Include="Scripts\Lib\angular-animate.js" />
@@ -1152,6 +1154,7 @@
11521154
<DependentUpon>ZenergyModel.edmx</DependentUpon>
11531155
</Content>
11541156
<Content Include="Views\Login\index.cshtml" />
1157+
<Content Include="Views\Register\index.cshtml" />
11551158
</ItemGroup>
11561159
<ItemGroup>
11571160
<Folder Include="App_Data\" />

0 commit comments

Comments
 (0)