Skip to content

Commit cbe8fce

Browse files
committed
Login facebook et google (en cours)
1 parent 0d8aad4 commit cbe8fce

File tree

4 files changed

+26
-10
lines changed

4 files changed

+26
-10
lines changed

Diff for: Zenergy/Zenergy/App_Start/Startup.Auth.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ public void ConfigureAuth(IAppBuilder app)
6363
appId: "429380533932654",
6464
appSecret: "ce6476f6a182519fee61ee17db94556d");
6565

66-
//app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
67-
//{
68-
// ClientId = "",
69-
// ClientSecret = ""
70-
//});
66+
app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
67+
{
68+
ClientId = "444754422502-l5urcdutcrgoedvdtrrbbvml2boq6eg2.apps.googleusercontent.com",
69+
ClientSecret = "mzj_gvPmB-pkCca_6U1VLkBE"
70+
});
7171
}
7272
}
7373
}

Diff for: Zenergy/Zenergy/Scripts/Controllers/homePageController.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
$scope.name = tokenService.getUserName();
33

44
$http({
5-
url: 'api/Account/ExternalLogin',
5+
url: '/api/Account/ExternalLogins?returnUrl=%2F&generateState=true',
66
method: 'GET'
77
}).then(function successCallback(response) {
8-
console.log(response.data);
9-
$scope.users = response.data;
8+
angular.forEach(response.data, function (value, key) {
9+
console.log(value);
10+
});
1011
}, function errorCallback(response) {
1112
});
13+
1214
}]);

Diff for: Zenergy/Zenergy/Scripts/Controllers/loginPageController.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
$scope.user = { mail: '', password: '' };
44
$scope.hasError = false;
5+
$http({
6+
url: '/api/Account/ExternalLogins?returnUrl=%2F&generateState=true',
7+
method: 'GET'
8+
}).then(function successCallback(response) {
9+
$scope.networks = response.data;
10+
}, function errorCallback(response) {
11+
});
12+
13+
514
$scope.connexion = function () {
615
var response = $http({
716
url: 'api/login',
@@ -21,6 +30,5 @@
2130
$scope.user.mail = '';
2231
$scope.user.password = '';
2332
});
24-
2533
};
2634
}]);

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
}
55
<div class="container " ng-controller="loginPageController">
66
<div class="row">
7-
<div class="col-md-3 col-lg-offset-4">
7+
<div class="col-md-3 col-lg-offset-2">
88
<h1>Sign in</h1>
99
<form ng-submit="connexion()">
1010
<div class="form-group" ng-class="{ 'has-error': hasError}">
@@ -17,6 +17,12 @@
1717
<input type="submit" id="submit" value="Sign in" class="btn btn-primary" />
1818
</form>
1919
</div>
20+
<div ng-cloak class="col-md-4 col-lg-offset-1">
21+
<h3>Or use a social network</h3>
22+
<a ng-repeat="(key, value) in networks" href="{{value.Url}}">
23+
<input type="button" value="{{value.Name}}" class="btn"/>
24+
</a>
25+
</div>
2026
</div>
2127
</div>
2228
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/md5.js"></script>

0 commit comments

Comments
 (0)