Skip to content

Commit

Permalink
Merge pull request #4689 from camptocamp/merge23
Browse files Browse the repository at this point in the history
 Merge remote-tracking branch 'origin/2.3'
  • Loading branch information
sbrunner committed Feb 26, 2019
2 parents 648e418 + f6544fc commit a3effc7
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 58 deletions.
2 changes: 1 addition & 1 deletion buildtools/check-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ page.onResourceError = function(resourceError) {
}
};
page.onResourceTimeout = page.onResourceError;
page.settings.resourceTimeout = 3000;
page.settings.resourceTimeout = 4000;
page.onUrlChanged = function(url) {
console.log('URL changed: ' + url);
};
Expand Down
3 changes: 1 addition & 2 deletions contribs/gmf/apps/desktop/index.html.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,7 @@
</ngeo-modal>
<ngeo-modal
ngeo-modal-closable="false"
ng-model="mainCtrl.userMustChangeItsPassword()"
ng-model-options="{getterSetter: true}">
ng-model="mainCtrl.userMustChangeItsPassword">
<div class="modal-header">
<h4 class="modal-title">
{{'You must change your password' | translate}}
Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/apps/desktop_alt/index.html.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@
</gmf-displayquerygrid>
</footer>
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=es6,default-3.6,Array.prototype.includes,Object.entries"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3&key=AIzaSyCYnqxEQA5sz13sWSgMr97ejzvUeGP8gz4"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3&key=AIzaSyA3NVIy-HOYT0a0CkChA6nFwqEFqHYWBVk"></script>
<% for (var chunk in htmlWebpackPlugin.files.chunks) { %>
<script src="<%= htmlWebpackPlugin.files.chunks[chunk].entry %>"></script>
<% } %>
Expand Down
3 changes: 1 addition & 2 deletions contribs/gmf/apps/mobile/index.html.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@
</gmf-authentication>
</nav>
<ngeo-modal
ng-model="mainCtrl.userMustChangeItsPassword()"
ng-model-options="{getterSetter: true}">
ng-model="mainCtrl.userMustChangeItsPassword">
<div class="modal-header">
<h4 class="modal-title">
{{'You must change your password' | translate}}
Expand Down
27 changes: 2 additions & 25 deletions contribs/gmf/src/authentication/component.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,41 +69,18 @@
type="button"
class="form-control btn btn-default"
value="{{'Cancel' | translate}}"
ng-if="!$ctrl.userMustChangeItsPassword()"
ng-if="!$ctrl.userMustChangeItsPassword"
ng-click="$ctrl.changePasswordReset()" />
<input
type="button"
class="form-control btn btn-default"
value="{{'Logout' | translate}}"
ng-if="$ctrl.userMustChangeItsPassword()"
ng-if="$ctrl.userMustChangeItsPassword"
ng-click="$ctrl.logout()" />
</div>
</form>

<div ng-show="$ctrl.error" class="gmf-authentication-error help-block"></div>

<ngeo-modal
ng-model="$ctrl.changePasswordModalShown">
<div class="modal-header">
<button type="button"
class="close"
data-dismiss="modal"
aria-label="{{'Close' | translate}}">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">
{{'Password Changed' | translate}}
</h4>
</div>
<div class="modal-body">
{{'Your password has successfully been changed.' | translate}}
</div>
<div class="modal-footer">
<button type="button"
class="btn btn-default"
data-dismiss="modal">{{'OK' | translate}}</button>
</div>
</ngeo-modal>
</div>

<div ng-if="!$ctrl.gmfUser.username">
Expand Down
29 changes: 14 additions & 15 deletions contribs/gmf/src/authentication/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ function gmfAuthenticationTemplateUrl($element, $attrs, gmfAuthenticationTemplat
*
* <ngeo-modal
* ngeo-modal-closable="false"
* ng-model="mainCtrl.userMustChangeItsPassword()"
* ng-model-options="{getterSetter: true}">
* ng-model="mainCtrl.userMustChangeItsPassword">
* <div class="modal-header">
* <h4 class="modal-title">
* {{'You must change your password' | translate}}
Expand Down Expand Up @@ -216,7 +215,7 @@ class AuthenticationController {
/**
* @type {boolean}
*/
this.changePasswordModalShown = false;
this.userMustChangeItsPassword = false;

/**
* @type {boolean}
Expand Down Expand Up @@ -268,6 +267,7 @@ class AuthenticationController {
if (this.forcePasswordChange) {
this.changingPassword = true;
}
this.userMustChangeItsPassword = (this.gmfUser.is_password_changed === false && this.forcePasswordChange);
}


Expand Down Expand Up @@ -318,8 +318,11 @@ class AuthenticationController {
// Send request with current credentials, which may fail if the old password given is incorrect.
this.gmfAuthenticationService_.changePassword(oldPwd, newPwd, confPwd)
.then(() => {
this.changePasswordModalShown = true;
this.changePasswordReset();
this.setError_(
[gettextCatalog.getString('Your password has successfully been changed.')],
MessageType.INFORMATION
);
})
.catch((err) => {
this.setError_(gettextCatalog.getString('Incorrect old password.'));
Expand Down Expand Up @@ -404,18 +407,14 @@ class AuthenticationController {
}

/**
* @return {boolean} True if the user must change is password and if the "forcePasswordChange" option of
* this component is set to true.
*/
userMustChangeItsPassword() {
return (this.gmfUser.is_password_changed === false && this.forcePasswordChange);
}

/**
* @param {string|Array.<string>} errors Errors.
* @param {string|Array<string>} errors Errors.
* @param {MessageType} [messageType] Type.
* @private
*/
setError_(errors) {
setError_(errors, messageType) {
if (messageType == undefined) {
messageType = MessageType.ERROR;
}
if (this.error) {
this.resetError_();
}
Expand All @@ -432,7 +431,7 @@ class AuthenticationController {
this.notification_.notify({
msg: error,
target: container,
type: MessageType.ERROR
type: messageType
});
}, this);
}
Expand Down
25 changes: 14 additions & 11 deletions contribs/gmf/src/controllers/AbstractAppController.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ export function AbstractAppController(config, map, $scope, $injector) {
*/
this.loginInfoMessage = null;

/**
* @type {boolean}
* @export
*/
this.userMustChangeItsPassword = false;

$scope.$on('authenticationrequired', (event, args) => {
/** @type {angular.gettext.gettextCatalog} */
const gettextCatalog = $injector.get('gettextCatalog');
Expand Down Expand Up @@ -381,6 +387,12 @@ export function AbstractAppController(config, map, $scope, $injector) {
* @type {import('gmf/authentication/Service.js').User}
*/
this.gmfUser = $injector.get('gmfUser');
$scope.$watch(
() => this.gmfUser.is_password_changed,
(value) => {
this.userMustChangeItsPassword = value === false;
}
);

/**
* @type {import('ngeo/misc/getBrowserLanguage.js').miscGetBrowserLanguage}
Expand Down Expand Up @@ -642,17 +654,8 @@ export function AbstractAppController(config, map, $scope, $injector) {


/**
* @return {boolean} Return true if a user exists and its 'is_password_changed' value is explicitly set
* to false.
*/
AbstractAppController.prototype.userMustChangeItsPassword = function() {
return this.gmfUser.is_password_changed === false;
};


/**
* @param {Array.<import("ol/layer/Base.js").default>} layers Layers list.
* @param {Array.<string>} labels default_basemap list.
* @param {Array<import("ol/layer/Base.js").default>} layers Layers list.
* @param {Array<string>} labels default_basemap list.
* @return {import("ol/layer/Base.js").default} layer or null
* @private
* @hidden
Expand Down
2 changes: 1 addition & 1 deletion examples/googlestreetview.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<label for="checkbox-dummy"> Dummy tool</label>
</div>
</div>
<script src="https://maps.googleapis.com/maps/api/js?v=3&key=AIzaSyCYnqxEQA5sz13sWSgMr97ejzvUeGP8gz4"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3&key=AIzaSyA3NVIy-HOYT0a0CkChA6nFwqEFqHYWBVk"></script>

</body>
</html>

0 comments on commit a3effc7

Please sign in to comment.