Skip to content

Commit

Permalink
✨ Multiple Auth-Methods on Login-Page
Browse files Browse the repository at this point in the history
Parent issue: sequentech/meta#916
  • Loading branch information
edulix committed Nov 6, 2024
1 parent 7a4f665 commit 4e39c0b
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 38 deletions.
16 changes: 16 additions & 0 deletions avRegistration/login-controller/login-controller.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,21 @@
selected-alt-method="{{selectedAltMethod}}"
>
</div>
<div ng-repeat="alt_method in alt_methods">
<div
av-login
event-id="{{event_id}}"
code="{{code}}"
email="{{email}}"
with-code="{{withCode}}"
username="{{username}}"
is-otl="{{isOtl}}"
is-open-id="{{isOpenId}}"
otl-secret="{{otlSecret}}"
with-alt-method="true"
selected-alt-method="{{alt_method}}"
>
</div>
</div>
</div>
</div>
26 changes: 25 additions & 1 deletion avRegistration/login-controller/login-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,32 @@ angular.module('avRegistration')
'LoginController',
function(
$scope,
$stateParams
$stateParams,
Authmethod
) {
$scope.alt_methods = [];
if (!$stateParams.altmethod) {
Authmethod
.viewEvent($stateParams.id)
.then(
function onSuccess(response) {
if (response.data.status !== "ok") {
return;
}
$scope.alt_methods = response
.data
.events
.alternative_auth_methods
.filter(function (auth_method) {
return auth_method.auth_method_name !== 'smart-link';
})
.map(function (auth_method) {
return auth_method.auth_method_name;
});
}
);
}

$scope.event_id = $stateParams.id;
$scope.code = $stateParams.code;
$scope.email = $stateParams.email;
Expand Down
33 changes: 0 additions & 33 deletions avRegistration/login-directive/login-directive.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,39 +32,6 @@
>
</div>
</div>

<!-- Shows the alternative auth method tabs in case there's any -->
<div class="col-sm-12 alternative-auth-methods-tabs" ng-if="alternative_auth_methods">
<ul class="nav nav-tabs" ng-if="method !== 'smart-link'">
<li
class="default-auth-method"
ng-class="{'active': current_alt_auth_method_id == null}"
>
<a
ng-click="setCurrentAltAuthMethod(null)"
>
<i class="fa fa-user"></i>
<span ng-i18next="avRegistration.defaultAuthMethod"></span>
</a>
</li>
<!-- we disable click for smart-link unless it comes from a smart-link,
because it doesn't work -->
<li
ng-repeat="alt_auth_method in alternative_auth_methods"
ng-class="{'active': current_alt_auth_method_id == alt_auth_method.id, 'disabled': selectedAltMethod !== 'smart-link' && alt_auth_method.auth_method_name === 'smart-link'}"
>
<a ng-click="setCurrentAltAuthMethod(alt_auth_method, true)">
<i
ng-if="alt_auth_method.icon"
class="{{alt_auth_method.icon}}"
></i>
<span>
{{getAltAuthMethodName(alt_auth_method)}}
</span>
</a>
</li>
</ul>
</div>

<div class="col-sm-12" ng-if="method !== 'openid-connect'">
<form name="form" id="loginForm" role="form" class="form-horizontal">
Expand Down
Loading

0 comments on commit 4e39c0b

Please sign in to comment.