Skip to content

Commit 0d8aad4

Browse files
committed
Redirection vers la page de login si non connecté
1 parent 2a34207 commit 0d8aad4

File tree

9 files changed

+138
-2
lines changed

9 files changed

+138
-2
lines changed

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

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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 ProfileController : Controller
10+
{
11+
// GET: Profile
12+
public ActionResult Index()
13+
{
14+
return View();
15+
}
16+
}
17+
}
+10-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1-
zenergyApp.controller("homePageController", ["$scope", "tokenService", function ($scope, tokenService) {
1+
zenergyApp.controller("homePageController", ["$scope", "tokenService","$http", function ($scope, tokenService, $http) {
22
$scope.name = tokenService.getUserName();
3+
4+
$http({
5+
url: 'api/Account/ExternalLogin',
6+
method: 'GET'
7+
}).then(function successCallback(response) {
8+
console.log(response.data);
9+
$scope.users = response.data;
10+
}, function errorCallback(response) {
11+
});
312
}]);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
zenergyApp.controller("profilePageController", ["$scope","tokenService", "$window", function ($scope, tokenService, $window) {
2+
if(!$scope.isConnected)
3+
window.location.replace("/Login");
4+
}]);

Diff for: Zenergy/Zenergy/Scripts/Lib/_references.js

132 Bytes
Binary file not shown.

Diff for: Zenergy/Zenergy/Views/Home/Index.cshtml

+1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
<p class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.</p>
77
<p><a href="http://asp.net" class="btn btn-primary btn-lg">Learn more &raquo;</a></p>
88
<p ng-cloak ng-show="isConnected">Connected AS : {{name}}</p>
9+
{{users}}
910
</div>

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<div class="form-group" ng-class="{ 'has-error': hasError}">
1414
<input type="password" class="form-control" ng-model="user.password" placeholder="Password">
1515
</div>
16-
<p class="text-danger" ng-if="hasError">Invalid email or password</p>
16+
<p ng-cloak class="text-danger" ng-if="hasError">Invalid email or password</p>
1717
<input type="submit" id="submit" value="Sign in" class="btn btn-primary" />
1818
</form>
1919
</div>

Diff for: Zenergy/Zenergy/Views/Profile/Index.cshtml

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
@model Zenergy.Models.user
2+
3+
@{
4+
ViewBag.Title = "Profile";
5+
}
6+
7+
<h2>Profile</h2>
8+
9+
10+
@using (Html.BeginForm())
11+
{
12+
@Html.AntiForgeryToken()
13+
14+
<div class="form-horizontal" ng-controller="profilePageController">
15+
<hr />
16+
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
17+
@Html.HiddenFor(model => model.userId)
18+
19+
<div class="form-group">
20+
@Html.LabelFor(model => model.password, htmlAttributes: new { @class = "control-label col-md-2" })
21+
<div class="col-md-10">
22+
@Html.EditorFor(model => model.password, new { htmlAttributes = new { @class = "form-control" } })
23+
@Html.ValidationMessageFor(model => model.password, "", new { @class = "text-danger" })
24+
</div>
25+
</div>
26+
27+
<div class="form-group">
28+
@Html.LabelFor(model => model.lastname, htmlAttributes: new { @class = "control-label col-md-2" })
29+
<div class="col-md-10">
30+
@Html.EditorFor(model => model.lastname, new { htmlAttributes = new { @class = "form-control" } })
31+
@Html.ValidationMessageFor(model => model.lastname, "", new { @class = "text-danger" })
32+
</div>
33+
</div>
34+
35+
<div class="form-group">
36+
@Html.LabelFor(model => model.firstname, htmlAttributes: new { @class = "control-label col-md-2" })
37+
<div class="col-md-10">
38+
@Html.EditorFor(model => model.firstname, new { htmlAttributes = new { @class = "form-control" } })
39+
@Html.ValidationMessageFor(model => model.firstname, "", new { @class = "text-danger" })
40+
</div>
41+
</div>
42+
43+
<div class="form-group">
44+
@Html.LabelFor(model => model.adr1, htmlAttributes: new { @class = "control-label col-md-2" })
45+
<div class="col-md-10">
46+
@Html.EditorFor(model => model.adr1, new { htmlAttributes = new { @class = "form-control" } })
47+
@Html.ValidationMessageFor(model => model.adr1, "", new { @class = "text-danger" })
48+
</div>
49+
</div>
50+
51+
<div class="form-group">
52+
@Html.LabelFor(model => model.adr2, htmlAttributes: new { @class = "control-label col-md-2" })
53+
<div class="col-md-10">
54+
@Html.EditorFor(model => model.adr2, new { htmlAttributes = new { @class = "form-control" } })
55+
@Html.ValidationMessageFor(model => model.adr2, "", new { @class = "text-danger" })
56+
</div>
57+
</div>
58+
59+
<div class="form-group">
60+
@Html.LabelFor(model => model.pc, htmlAttributes: new { @class = "control-label col-md-2" })
61+
<div class="col-md-10">
62+
@Html.EditorFor(model => model.pc, new { htmlAttributes = new { @class = "form-control" } })
63+
@Html.ValidationMessageFor(model => model.pc, "", new { @class = "text-danger" })
64+
</div>
65+
</div>
66+
67+
<div class="form-group">
68+
@Html.LabelFor(model => model.town, htmlAttributes: new { @class = "control-label col-md-2" })
69+
<div class="col-md-10">
70+
@Html.EditorFor(model => model.town, new { htmlAttributes = new { @class = "form-control" } })
71+
@Html.ValidationMessageFor(model => model.town, "", new { @class = "text-danger" })
72+
</div>
73+
</div>
74+
75+
<div class="form-group">
76+
@Html.LabelFor(model => model.mail, htmlAttributes: new { @class = "control-label col-md-2" })
77+
<div class="col-md-10">
78+
@Html.EditorFor(model => model.mail, new { htmlAttributes = new { @class = "form-control" } })
79+
@Html.ValidationMessageFor(model => model.mail, "", new { @class = "text-danger" })
80+
</div>
81+
</div>
82+
83+
<div class="form-group">
84+
@Html.LabelFor(model => model.phone, htmlAttributes: new { @class = "control-label col-md-2" })
85+
<div class="col-md-10">
86+
@Html.EditorFor(model => model.phone, new { htmlAttributes = new { @class = "form-control" } })
87+
@Html.ValidationMessageFor(model => model.phone, "", new { @class = "text-danger" })
88+
</div>
89+
</div>
90+
91+
<div class="form-group">
92+
<div class="col-md-offset-2 col-md-10">
93+
<input type="submit" value="Save" class="btn btn-default" />
94+
</div>
95+
</div>
96+
</div>
97+
}
98+
99+
@section Scripts {
100+
@Scripts.Render("~/bundles/jqueryval")
101+
}

Diff for: Zenergy/Zenergy/Views/Shared/_Layout.cshtml

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<li>@Html.ActionLink("API", "Index", "Help", new { area = "" }, null)</li>
2727
</ul>
2828
<ul ng-cloak class="nav navbar-nav navbar-right" ng-show="isConnected">
29+
<li>@Html.ActionLink("Profile", "Index", "Profile", new { area = "" }, null)</li>
2930
<li><a href="#" ng-click="logoff()">Log Off</a></li>
3031
</ul>
3132
<ul ng-cloak class="nav navbar-nav navbar-right" ng-hide="isConnected">

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\ProfileController.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\profilePageController.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\Profile\Index.cshtml" />
11551158
</ItemGroup>
11561159
<ItemGroup>
11571160
<Folder Include="App_Data\" />

0 commit comments

Comments
 (0)