mirror of https://github.com/portainer/portainer
feat(oauth): update authentication panel with OAuth provider details
parent
e325ad10dd
commit
9918c1260b
|
@ -29,8 +29,17 @@
|
|||
<div class="form-group">
|
||||
<div class="col-sm-12" >
|
||||
<a ng-href="{{OAuthLoginURI}}" ng-if="AuthenticationMethod === 3">
|
||||
<div class="btn btn-primary btn-sm pull-left" style="margin-left:2px">
|
||||
<i class="fa fa-sign-in-alt" aria-hidden="true"></i> Login with OAuth
|
||||
<div class="btn btn-primary btn-sm pull-left" style="margin-left:2px" ng-if="state.OAuthProvider === 'Microsoft'">
|
||||
<i class="fab fa-microsoft" aria-hidden="true"></i> Login with Microsoft
|
||||
</div>
|
||||
<div class="btn btn-primary btn-sm pull-left" style="margin-left:2px" ng-if="state.OAuthProvider === 'Google'">
|
||||
<i class="fab fa-google" aria-hidden="true" ></i> Login with Google
|
||||
</div>
|
||||
<div class="btn btn-primary btn-sm pull-left" style="margin-left:2px" ng-if="state.OAuthProvider === 'Github'">
|
||||
<i class="fab fa-github" aria-hidden="true" ></i> Login with Github
|
||||
</div>
|
||||
<div class="btn btn-primary btn-sm pull-left" style="margin-left:2px" ng-if="state.OAuthProvider === ''">
|
||||
<i class="fa fa-sign-in-alt" aria-hidden="true" ></i> Login with OAuth
|
||||
</div>
|
||||
</a>
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
angular.module('portainer.app').controller('AuthenticationController', ['$q', '$scope', '$state', '$stateParams', '$sanitize', 'Authentication', 'UserService', 'EndpointService', 'StateManager', 'Notifications', 'SettingsService', 'URLHelper',
|
||||
function($q, $scope, $state, $stateParams, $sanitize, Authentication, UserService, EndpointService, StateManager, Notifications, SettingsService, URLHelper) {
|
||||
angular.module('portainer.app')
|
||||
.controller('AuthenticationController', ['$q', '$scope', '$state', '$stateParams', '$sanitize', 'Authentication', 'UserService', 'EndpointService', 'StateManager', 'Notifications', 'SettingsService', 'URLHelper',
|
||||
function($q, $scope, $state, $stateParams, $sanitize, Authentication, UserService, EndpointService, StateManager, Notifications, SettingsService, URLHelper) {
|
||||
$scope.logo = StateManager.getState().application.logo;
|
||||
|
||||
$scope.formValues = {
|
||||
|
@ -9,7 +10,8 @@ angular.module('portainer.app').controller('AuthenticationController', ['$q', '$
|
|||
|
||||
$scope.state = {
|
||||
AuthenticationError: '',
|
||||
isInOAuthProcess: true
|
||||
isInOAuthProcess: true,
|
||||
OAuthProvider: ''
|
||||
};
|
||||
|
||||
$scope.authenticateUser = function() {
|
||||
|
@ -80,11 +82,25 @@ angular.module('portainer.app').controller('AuthenticationController', ['$q', '$
|
|||
});
|
||||
}
|
||||
|
||||
function determineOauthProvider(LoginURI) {
|
||||
if (LoginURI.indexOf('login.microsoftonline.com') !== -1) {
|
||||
return 'Microsoft';
|
||||
}
|
||||
else if (LoginURI.indexOf('accounts.google.com') !== -1) {
|
||||
return 'Google';
|
||||
}
|
||||
else if (LoginURI.indexOf('github.com') !== -1) {
|
||||
return 'Github';
|
||||
}
|
||||
return 'OAuth';
|
||||
}
|
||||
|
||||
function initView() {
|
||||
SettingsService.publicSettings()
|
||||
.then(function success(settings) {
|
||||
$scope.AuthenticationMethod = settings.AuthenticationMethod;
|
||||
$scope.OAuthLoginURI = settings.OAuthLoginURI;
|
||||
$scope.state.OAuthProvider = determineOauthProvider(settings.OAuthLoginURI);
|
||||
});
|
||||
|
||||
if ($stateParams.logout || $stateParams.error) {
|
||||
|
@ -127,4 +143,4 @@ angular.module('portainer.app').controller('AuthenticationController', ['$q', '$
|
|||
|
||||
|
||||
initView();
|
||||
}]);
|
||||
}]);
|
||||
|
|
Loading…
Reference in New Issue