Skip to content
This repository was archived by the owner on Mar 6, 2023. It is now read-only.

Commit 3e9e307

Browse files
committed
Fixes #20 don't show the oauth providers unless they are configured
This also streamlines the self hosted setup experience exceptionless/Exceptionless#77 We couldn’t share the isExternalLoginEnabled logic because none of the views share a common controller.
1 parent a718070 commit 3e9e307

File tree

6 files changed

+82
-22
lines changed

6 files changed

+82
-22
lines changed

src/app/account/manage-controller.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
'use strict';
33

44
angular.module('app.account')
5-
.controller('account.Manage', ['$stateParams', '$timeout', 'authService', 'billingService', 'featureService', 'notificationService', 'projectService', 'userService', function ($stateParams, $timeout, authService, billingService, featureService, notificationService, projectService, userService) {
5+
.controller('account.Manage', ['$stateParams', '$timeout', 'authService', 'billingService', 'FACEBOOK_APPID', 'featureService', 'GOOGLE_APPID', 'GITHUB_APPID', 'LIVE_APPID', 'notificationService', 'projectService', 'userService', function ($stateParams, $timeout, authService, billingService, FACEBOOK_APPID, featureService, GOOGLE_APPID, GITHUB_APPID, LIVE_APPID, notificationService, projectService, userService) {
66
var _canSaveEmailAddress = true;
77
var vm = this;
88

@@ -143,6 +143,25 @@
143143
return hasEmailNotifications() && hasPremiumFeatures();
144144
}
145145

146+
function isExternalLoginEnabled(provider) {
147+
if (!provider) {
148+
return !!FACEBOOK_APPID || !!GITHUB_APPID || !!GOOGLE_APPID || !!LIVE_APPID;
149+
}
150+
151+
switch (provider) {
152+
case 'facebook':
153+
return !!FACEBOOK_APPID;
154+
case 'github':
155+
return !!GITHUB_APPID;
156+
case 'google':
157+
return !!GOOGLE_APPID;
158+
case 'live':
159+
return !!LIVE_APPID;
160+
default:
161+
return false;
162+
}
163+
}
164+
146165
function resendVerificationEmail() {
147166
function onFailure(response) {
148167
var message = 'An error occurred while sending your verification email.';
@@ -274,6 +293,7 @@
274293
vm.hasPremiumEmailNotifications = hasPremiumEmailNotifications;
275294
vm.hasPremiumFeatures = hasPremiumFeatures;
276295
vm.hasProjects = hasProjects;
296+
vm.isExternalLoginEnabled;
277297
vm.password = {};
278298
vm.passwordForm = {};
279299
vm.projects = [];

src/app/account/manage.tpl.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,14 @@
210210
<button type="submit" role="button" class="btn btn-primary" promise-button="vm.changePassword(vm.passwordForm.$valid)" promise-button-busy-text="{{vm.hasLocalAccount() ? 'Changing Password' : 'Setting Password'}}">{{vm.hasLocalAccount() ? 'Change Password' : 'Set Password'}}</button>
211211
</form>
212212
</tab>
213-
<tab heading="External Logins" active="vm.tabExternalActive">
213+
<tab heading="External Logins" active="vm.tabExternalActive" ng-if="vm.isExternalLoginEnabled()">
214214
<h4>Add an external login</h4>
215215

216216
<div>
217-
<button type="button" role="button" ng-click="vm.authenticate('live')" class="btn btn-large image-button icon-login-microsoft" title="Log in using your Microsoft account"></button>
218-
<button type="button" role="button" ng-click="vm.authenticate('google')" class="btn btn-large image-button icon-login-google" title="Log in using your Google account"></button>
219-
<button type="button" role="button" ng-click="vm.authenticate('facebook')" class="btn btn-large image-button icon-login-facebook" title="Log in using your Facebook account"></button>
220-
<button type="button" role="button" ng-click="vm.authenticate('github')" class="btn btn-large image-button icon-login-github" title="Log in using your GitHub account"></button>
217+
<button type="button" role="button" ng-click="vm.authenticate('live')" ng-if="vm.isExternalLoginEnabled('live')" class="btn btn-large image-button icon-login-microsoft" title="Log in using your Microsoft account"></button>
218+
<button type="button" role="button" ng-click="vm.authenticate('google')" ng-if="vm.isExternalLoginEnabled('google')" class="btn btn-large image-button icon-login-google" title="Log in using your Google account"></button>
219+
<button type="button" role="button" ng-click="vm.authenticate('facebook')" ng-if="vm.isExternalLoginEnabled('facebook')" class="btn btn-large image-button icon-login-facebook" title="Log in using your Facebook account"></button>
220+
<button type="button" role="button" ng-click="vm.authenticate('github')" ng-if="vm.isExternalLoginEnabled('github')" class="btn btn-large image-button icon-login-github" title="Log in using your GitHub account"></button>
221221
</div>
222222

223223
<h4>Existing external logins</h4>

src/app/auth/login-controller.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
'use strict';
33

44
angular.module('app.auth')
5-
.controller('auth.Login', ['$state', '$stateParams', 'authService', 'notificationService', 'projectService', 'stateService', function ($state, $stateParams, authService, notificationService, projectService, stateService) {
5+
.controller('auth.Login', ['$state', '$stateParams', 'authService', 'FACEBOOK_APPID', 'GOOGLE_APPID', 'GITHUB_APPID', 'LIVE_APPID', 'notificationService', 'projectService', 'stateService', function ($state, $stateParams, authService, FACEBOOK_APPID, GOOGLE_APPID, GITHUB_APPID, LIVE_APPID, notificationService, projectService, stateService) {
66
var vm = this;
77

88
function getMessage(response) {
@@ -21,6 +21,25 @@
2121
return authService.authenticate(provider, { InviteToken: vm.token }).then(redirectOnSignup, onFailure);
2222
}
2323

24+
function isExternalLoginEnabled(provider) {
25+
if (!provider) {
26+
return !!FACEBOOK_APPID || !!GITHUB_APPID || !!GOOGLE_APPID || !!LIVE_APPID;
27+
}
28+
29+
switch (provider) {
30+
case 'facebook':
31+
return !!FACEBOOK_APPID;
32+
case 'github':
33+
return !!GITHUB_APPID;
34+
case 'google':
35+
return !!GOOGLE_APPID;
36+
case 'live':
37+
return !!LIVE_APPID;
38+
default:
39+
return false;
40+
}
41+
}
42+
2443
function login(isValid) {
2544
if (!isValid) {
2645
return;
@@ -55,6 +74,7 @@
5574
}
5675

5776
vm.authenticate = authenticate;
77+
vm.isExternalLoginEnabled = isExternalLoginEnabled;
5878
vm.login = login;
5979
vm.token = $stateParams.token;
6080
vm.user = { invite_token: vm.token };

src/app/auth/login.tpl.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
<div class="panel-body">
1515
<form name="loginForm" role="form" class="form-horizontal form-validation" autocomplete="on">
1616
<div class="form-horizontal col-sm-offset-2">
17-
<h4>Login with</h4>
17+
<h4>Login <span ng-if="vm.isExternalLoginEnabled()">with</span></h4>
1818

19-
<div class="form-group" style="margin-left:0px;">
20-
<button type="button" role="button" ng-click="vm.authenticate('live')" class="btn btn-large image-button icon-login-microsoft" title="Log in using your Microsoft account"></button>
21-
<button type="button" role="button" ng-click="vm.authenticate('google')" class="btn btn-large image-button icon-login-google" title="Log in using your Google account"></button>
22-
<button type="button" role="button" ng-click="vm.authenticate('facebook')" class="btn btn-large image-button icon-login-facebook" title="Log in using your Facebook account"></button>
23-
<button type="button" role="button" ng-click="vm.authenticate('github')" class="btn btn-large image-button icon-login-github" title="Log in using your GitHub account"></button>
19+
<div class="form-group" style="margin-left:0px;" ng-if="vm.isExternalLoginEnabled()">
20+
<button type="button" role="button" ng-click="vm.authenticate('live')" ng-if="vm.isExternalLoginEnabled('live')" class="btn btn-large image-button icon-login-microsoft" title="Log in using your Microsoft account"></button>
21+
<button type="button" role="button" ng-click="vm.authenticate('google')" ng-if="vm.isExternalLoginEnabled('google')" class="btn btn-large image-button icon-login-google" title="Log in using your Google account"></button>
22+
<button type="button" role="button" ng-click="vm.authenticate('facebook')" ng-if="vm.isExternalLoginEnabled('facebook')" class="btn btn-large image-button icon-login-facebook" title="Log in using your Facebook account"></button>
23+
<button type="button" role="button" ng-click="vm.authenticate('github')" ng-if="vm.isExternalLoginEnabled('github')" class="btn btn-large image-button icon-login-github" title="Log in using your GitHub account"></button>
2424
</div>
2525

26-
<div class="form-group">
26+
<div class="form-group" ng-if="vm.isExternalLoginEnabled()">
2727
<div class="col-sm-10 horizontal-divider">
2828
<p>OR</p>
2929
<span></span>

src/app/auth/signup-controller.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
'use strict';
33

44
angular.module('app.auth')
5-
.controller('auth.Signup', ['$state', '$stateParams', '$timeout', 'authService', 'notificationService', 'projectService', 'stateService', function ($state, $stateParams, $timeout, authService, notificationService, projectService, stateService) {
5+
.controller('auth.Signup', ['$state', '$stateParams', '$timeout', 'authService', 'FACEBOOK_APPID', 'GOOGLE_APPID', 'GITHUB_APPID', 'LIVE_APPID', 'notificationService', 'projectService', 'stateService', function ($state, $stateParams, $timeout, authService, FACEBOOK_APPID, GOOGLE_APPID, GITHUB_APPID, LIVE_APPID, notificationService, projectService, stateService) {
66
var _canSignup = true;
77
var vm = this;
88

@@ -22,6 +22,25 @@
2222
return authService.authenticate(provider, { InviteToken: vm.token }).then(redirectOnSignup, onFailure);
2323
}
2424

25+
function isExternalLoginEnabled(provider) {
26+
if (!provider) {
27+
return !!FACEBOOK_APPID || !!GITHUB_APPID || !!GOOGLE_APPID || !!LIVE_APPID;
28+
}
29+
30+
switch (provider) {
31+
case 'facebook':
32+
return !!FACEBOOK_APPID;
33+
case 'github':
34+
return !!GITHUB_APPID;
35+
case 'google':
36+
return !!GOOGLE_APPID;
37+
case 'live':
38+
return !!LIVE_APPID;
39+
default:
40+
return false;
41+
}
42+
}
43+
2544
function redirectOnSignup() {
2645
function onSuccess(response) {
2746
if (response.data && response.data.length > 0) {
@@ -75,6 +94,7 @@
7594
}
7695

7796
vm.authenticate = authenticate;
97+
vm.isExternalLoginEnabled = isExternalLoginEnabled;
7898
vm.signup = signup;
7999
vm.signupForm = {};
80100
vm.token = $stateParams.token;

src/app/auth/signup.tpl.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
<div class="panel-body">
1616
<form name="vm.signupForm" role="form" class="form-horizontal form-validation" autocomplete="on">
1717
<div class="form-horizontal col-sm-offset-2">
18-
<h4>Login with</h4>
18+
<h4 ng-if="vm.isExternalLoginEnabled()">Login with</h4>
1919

20-
<div class="form-group" style="margin-left:0px;">
21-
<button type="button" role="button" ng-click="vm.authenticate('live')" class="btn btn-large image-button icon-login-microsoft" title="Log in using your Microsoft account"></button>
22-
<button type="button" role="button" ng-click="vm.authenticate('google')" class="btn btn-large image-button icon-login-google" title="Log in using your Google account"></button>
23-
<button type="button" role="button" ng-click="vm.authenticate('facebook')" class="btn btn-large image-button icon-login-facebook" title="Log in using your Facebook account"></button>
24-
<button type="button" role="button" ng-click="vm.authenticate('github')" class="btn btn-large image-button icon-login-github" title="Log in using your GitHub account"></button>
20+
<div class="form-group" style="margin-left:0px;" ng-if="vm.isExternalLoginEnabled()">
21+
<button type="button" role="button" ng-click="vm.authenticate('live')" ng-if="vm.isExternalLoginEnabled('live')" class="btn btn-large image-button icon-login-microsoft" title="Log in using your Microsoft account"></button>
22+
<button type="button" role="button" ng-click="vm.authenticate('google')" ng-if="vm.isExternalLoginEnabled('google')" class="btn btn-large image-button icon-login-google" title="Log in using your Google account"></button>
23+
<button type="button" role="button" ng-click="vm.authenticate('facebook')" ng-if="vm.isExternalLoginEnabled('facebook')" class="btn btn-large image-button icon-login-facebook" title="Log in using your Facebook account"></button>
24+
<button type="button" role="button" ng-click="vm.authenticate('github')" ng-if="vm.isExternalLoginEnabled('github')" class="btn btn-large image-button icon-login-github" title="Log in using your GitHub account"></button>
2525
</div>
2626

27-
<div class="form-group">
27+
<div class="form-group" ng-if="vm.isExternalLoginEnabled()">
2828
<div class="col-sm-10 horizontal-divider">
2929
<p>OR</p>
3030
<span></span>

0 commit comments

Comments
 (0)