forked from camunda/camunda-bpm-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(webapps): add login plugin point (camunda#3461)
related to camunda#3412
- Loading branch information
Showing
9 changed files
with
177 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
webapps/frontend/camunda-commons-ui/lib/auth/page/form.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!-- # CE - camunda-commons-ui/lib/auth/page/form.html --> | ||
<form ng-submit="login()" | ||
name="signinForm" | ||
request-aware> | ||
|
||
<input autofocus | ||
tabindex="1" | ||
type="text" | ||
class="form-control" | ||
placeholder="{{ 'PAGE_LOGIN_USERNAME' | translate }}" | ||
auto-fill | ||
required | ||
ng-model="username"></input> | ||
<input tabindex="2" | ||
type="password" | ||
class="form-control" | ||
placeholder="{{ 'PAGE_LOGIN_PASSWORD' | translate }}" | ||
auto-fill | ||
required | ||
ng-model="password"></input> | ||
<button tabindex="3" | ||
class="btn btn-lg btn-primary" | ||
type="submit" | ||
ng-disabled="status === 'LOADING'">{{ 'PAGE_LOGIN_SIGN_IN_ACTION' | translate }} | ||
</button> | ||
</form> | ||
<!-- / CE - camunda-commons-ui/lib/auth/page/form.html --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH | ||
* under one or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information regarding copyright | ||
* ownership. Camunda licenses this file to you under the Apache License, | ||
* Version 2.0; you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
const $ = require('jquery'); | ||
module.exports = [ | ||
'$scope', | ||
'AuthenticationService', | ||
'Notifications', | ||
'$translate', | ||
'Views', | ||
'canonicalAppName', | ||
function( | ||
$scope, | ||
AuthenticationService, | ||
Notifications, | ||
$translate, | ||
views, | ||
canonicalAppName | ||
) { | ||
$scope.status = 'INIT'; | ||
|
||
// ensure focus on username input | ||
var autofocusField = $('form[name="signinForm"] [autofocus]')[0]; | ||
if (autofocusField) { | ||
autofocusField.focus(); | ||
} | ||
|
||
const loginDataPlugins = views.getProviders({ | ||
component: `${canonicalAppName}.login.data` | ||
}); | ||
|
||
$scope.login = function() { | ||
$scope.status = 'LOADING'; | ||
const loginDataPromise = AuthenticationService.login( | ||
$scope.username, | ||
$scope.password | ||
); | ||
|
||
loginDataPlugins.forEach(loginDataPlugin => { | ||
loginDataPlugin.result && | ||
loginDataPlugin.result(loginDataPromise, $scope); | ||
}); | ||
|
||
return loginDataPromise | ||
.then(function() { | ||
$scope.status = 'DONE'; | ||
Notifications.clearAll(); | ||
$scope.$root.$broadcast('first-visit-info-box-dismissed'); | ||
}) | ||
.catch(function(error) { | ||
$scope.status = 'ERROR'; | ||
delete $scope.username; | ||
delete $scope.password; | ||
|
||
Notifications.addError({ | ||
status: $translate.instant('PAGE_LOGIN_FAILED'), | ||
message: | ||
(error.data && error.data.message) || | ||
$translate.instant('PAGE_LOGIN_ERROR_MSG'), | ||
scope: $scope, | ||
exclusive: true | ||
}); | ||
}); | ||
}; | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,6 @@ | |
|
||
.btn-primary { | ||
width: 100%; | ||
float: right; | ||
} | ||
|
||
.alert-info { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
webapps/frontend/camunda-commons-ui/lib/services/canocialAppName.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH | ||
* under one or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information regarding copyright | ||
* ownership. Camunda licenses this file to you under the Apache License, | ||
* Version 2.0; you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const base = document.querySelector('base'); | ||
const canonicalAppName = base.getAttribute('app-name'); | ||
|
||
module.exports = function() { | ||
this.$get = function() { | ||
return canonicalAppName; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters