Merge branch 'master' of github.com:wso2/carbon-device-mgt

merge-requests/7/head
Chatura Dilan Perera 8 years ago
commit 7395c76408

@ -21,7 +21,6 @@ package org.wso2.carbon.device.mgt.jaxrs.service.api;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.wso2.carbon.apimgt.annotations.api.API; import org.wso2.carbon.apimgt.annotations.api.API;
import org.wso2.carbon.apimgt.annotations.api.Permission; import org.wso2.carbon.apimgt.annotations.api.Permission;
import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.device.mgt.jaxrs.beans.*; import org.wso2.carbon.device.mgt.jaxrs.beans.*;
import javax.ws.rs.*; import javax.ws.rs.*;
@ -471,7 +470,7 @@ public interface UserManagementService {
"Server error occurred while updating credentials of the user.", "Server error occurred while updating credentials of the user.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) })
@Permission(name = "View Users", permission = "/device-mgt/users/view") @Permission(name = "Reset user password", permission = "/login")
Response resetPassword( Response resetPassword(
@ApiParam( @ApiParam(
name = "username", name = "username",

@ -1,3 +1,21 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); 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.
*/
/** /**
* Checks if provided input is valid against RegEx input. * Checks if provided input is valid against RegEx input.
* *
@ -21,34 +39,33 @@ $(document).ready(function () {
showPopup(); showPopup();
$("a#change-password-yes-link").click(function () { $("a#change-password-yes-link").click(function () {
var oldPassword = $("#old-password").val(); var currentPassword = $("#current-password").val();
var newPassword = $("#new-password").val(); var newPassword = $("#new-password").val();
var confirmedPassword = $("#confirmed-password").val(); var retypedNewPassword = $("#retyped-new-password").val();
var user = $("#user").val(); var user = $("#user").val();
var errorMsgWrapper = "#notification-error-msg"; var errorMsgWrapper = "#change-password-error-msg";
var errorMsg = "#notification-error-msg span"; var errorMsg = "#change-password-error-msg span";
if (!oldPassword) { if (!currentPassword) {
$(errorMsg).text("Old password is a required field. It cannot be empty."); $(errorMsg).text("Typing your current password is required. It cannot be empty.");
$(errorMsgWrapper).removeClass("hidden"); $(errorMsgWrapper).removeClass("hidden");
} else if (!newPassword) { } else if (!newPassword) {
$(errorMsg).text("New password is a required field. It cannot be empty."); $(errorMsg).text("Typing your new password is required. It cannot be empty.");
$(errorMsgWrapper).removeClass("hidden"); $(errorMsgWrapper).removeClass("hidden");
} else if (!confirmedPassword) { } else if (!retypedNewPassword) {
$(errorMsg).text("Retyping the new password is required."); $(errorMsg).text("Confirming your new password is required. It cannot be empty.");
$(errorMsgWrapper).removeClass("hidden"); $(errorMsgWrapper).removeClass("hidden");
} else if (confirmedPassword != newPassword) { } else if (retypedNewPassword != newPassword) {
$(errorMsg).text("New password doesn't match the confirmation."); $(errorMsg).text("Password confirmation failed. Please check.");
$(errorMsgWrapper).removeClass("hidden"); $(errorMsgWrapper).removeClass("hidden");
} else if (!inputIsValid(/^[\S]{5,30}$/, confirmedPassword)) { } else if (!inputIsValid(/^[\S]{5,30}$/, newPassword)) {
$(errorMsg).text("Password should be minimum 5 characters long, should not include any whitespaces."); $(errorMsg).text("Password should be minimum 5 characters long and " +
"should not include any whitespaces. Please check.");
$(errorMsgWrapper).removeClass("hidden"); $(errorMsgWrapper).removeClass("hidden");
} else { } else {
var changePasswordFormData = {}; var changePasswordFormData = {};
//changePasswordFormData.username = user; changePasswordFormData["oldPassword"] = unescape((currentPassword));
changePasswordFormData.newPassword = unescape((confirmedPassword)); changePasswordFormData["newPassword"] = unescape((newPassword));
changePasswordFormData.oldPassword = unescape((oldPassword));
var changePasswordAPI = "/api/device-mgt/v1.0/users/" + user + "/credentials"; var changePasswordAPI = "/api/device-mgt/v1.0/users/" + user + "/credentials";
@ -64,7 +81,7 @@ $(document).ready(function () {
} }
}, function (jqXHR) { }, function (jqXHR) {
if (jqXHR.status == 400) { if (jqXHR.status == 400) {
$(errorMsg).text("Old password does not match with the provided value."); $(errorMsg).text("Your current password does not match with the provided value.");
$(errorMsgWrapper).removeClass("hidden"); $(errorMsgWrapper).removeClass("hidden");
} else { } else {
$(errorMsg).text("An unexpected error occurred. Please try again later."); $(errorMsg).text("An unexpected error occurred. Please try again later.");

@ -15,73 +15,91 @@
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
}} }}
{{#zone "userMenu-items"}} {{#zone "userMenu-items"}}
<li> <li>
<a href="javascript:void(0)" id="change-password">Change password</a> <a href="javascript:void(0)" id="change-password">Change password</a>
</li> </li>
<li> <li>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/logout">Sign out</a> <a href="{{@app.context}}/logout">Sign out</a>
</li> </li>
<div id="change-password-window" class="hide"> <div id="change-password-window" class="hide">
<input type="hidden" id="user" value="{{username}}"> <input type="hidden" id="user" value="{{username}}">
<div class="modal-header"> <div class="modal-header">
<h3 class="pull-left modal-title"> <h4 class="pull-left modal-title">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-user fw-stack-2x"></i>
<i class="fw fw-key fw-stack-1x"></i> <span class="fw-stack fw-move-right fw-move-bottom">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-circle fw-stack-2x fw-stroke text-info"></i>
<i class="fw fw-edit fw-stack-1x fw-inverse"></i>
</span>
</span> </span>
Change Password &nbsp;&nbsp;Change password
</h3> </h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
</div> </div>
<hr>
<div class="modal-body add-margin-top-2x add-margin-bottom-2x"> <div class="modal-body add-margin-top-2x add-margin-bottom-2x">
<div id="notification-error-msg" class="alert alert-danger hidden" role="alert"> <div id="change-password-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span> <i class="icon fw fw-error"></i><span></span>
</div> </div>
<h3> <h5>
Enter old password * Type your current password *
<br><br> <br><br>
<div> <div>
<input type="password" class="form-control modal-input operationDataKeys" id="old-password" data-key="message"/> <input id="current-password" type="password" class="form-control modal-input"/>
</div> </div>
<br> <br><br>
Enter new password * Type a new password *
<br><br> <br><br>
<div> <div>
<input type="password" class="form-control modal-input operationDataKeys" id="new-password" data-key="message"/> <input id="new-password" type="password" class="form-control modal-input"
placeholder="[ Password should be in minimum 5 characters long and should not include any whitespaces ]"/>
</div> </div>
<br> <br><br>
Retype new password * Reconfirm your new password *
<br><br> <br><br>
<div> <div>
<input type="password" class="form-control modal-input operationDataKeys" id="confirmed-password" data-key="message"/> <input id="retyped-new-password" type="password" class="form-control modal-input"/>
</div> </div>
<br> <br><br>
</h3> </h5>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<div class="buttons"> <div class="buttons">
<a href="#" id="change-password-yes-link" class="btn-operations">Update</a> <a href="#" id="change-password-yes-link" class="btn-operations">Change</a>
<a href="#" id="change-password-cancel-link" class="btn-operations">Cancel</a> <a href="#" id="change-password-cancel-link" class="btn-operations">Cancel</a>
</div> </div>
</div> </div>
</div> </div>
<div id="change-password-success-content" class="hide"> <div id="change-password-success-content" class="hide">
<div class="content"> <div class="modal-header">
<div class="row"> <h4 class="pull-left modal-title">
<div class="col-lg-5 col-md-6 col-centered"> <span class="fw-stack fw-move-right fw-move-bottom">
<h3>Password change is successful.</h3> <i class="fw fw-circle fw-stack-2x fw-stroke text-success"></i>
<div class="buttons"> <i class="fw fw-check fw-stack-1x fw-inverse"></i>
<a href="#" id="change-password-success-link" class="btn-operations">Ok</a> </span>
</div> &nbsp;&nbsp;Password has been successfully updated
</div> </h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
</div>
<hr>
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
<h5 class="text-center">
You can now try to login using your new password.
</h5>
</div>
<div class="modal-footer">
<div class="buttons">
<a href="#" id="change-password-success-link" class="btn-operations">Ok</a>
</div> </div>
</div> </div>
</div> </div>
{{/zone}} {{/zone}}
{{#zone "bottomJs"}} {{#zone "bottomJs"}}
<script src="{{@unit.publicUri}}/js/user-menu.js"></script> {{js "/js/user-menu.js"}}
{{/zone}} {{/zone}}

@ -1,3 +1,21 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); 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.
*/
function onRequest() { function onRequest() {
var constants = require("/app/modules/constants.js"); var constants = require("/app/modules/constants.js");
return session.get(constants["USER_SESSION_KEY"]); return session.get(constants["USER_SESSION_KEY"]);

@ -105,7 +105,7 @@
data-offset-top="80"> data-offset-top="80">
<ul class="sidebar-messages"> <ul class="sidebar-messages">
</ul> </ul>
<div class="text-center"><a href="{{appContext}}notification-listing" class="btn btn-primary">Show all notifications</a></div> <div class="text-center"><a href="{{appContext}}notification-listing" class="btn btn-primary">Show All Notifications</a></div>
</div> </div>
{{/zone}} {{/zone}}
{{#zone "bottomJs"}} {{#zone "bottomJs"}}

@ -102,23 +102,28 @@ function loadNewNotifications() {
if (responsePayload.count > 0) { if (responsePayload.count > 0) {
$(messageSideBar).html(template(viewModel)); $(messageSideBar).html(template(viewModel));
} else { } else {
$(messageSideBar).html("<h4 class='text-center'>No new notifications found...</h4>"); $(messageSideBar).html(
"<h4 class='text-center'>No New Notifications</h4>" +
"<h5 class='text-center text-muted'>" +
"Check this section for error notifications<br>related to device operations" +
"</h5>"
);
} }
} else { } else {
$(messageSideBar).html("<h4 class ='message-danger'>Unexpected error occurred while loading new notifications.</h4>"); $(messageSideBar).html("<h4 class ='message-danger text-center'>Unexpected error occurred while loading new notifications</h4>");
} }
} }
}; };
var errorCallback = function (jqXHR) { var errorCallback = function (jqXHR) {
if (jqXHR.status = 500) { if (jqXHR.status = 500) {
$(messageSideBar).html("<h4 class ='message-danger'>Unexpected error occurred while trying " + $(messageSideBar).html("<h4 class ='message-danger text-center'>Unexpected error occurred while trying " +
"to retrieve any new notifications.</h4>"); "to retrieve any new notifications</h4>");
} }
}; };
invokerUtil.get(serviceURL, successCallback, errorCallback); invokerUtil.get(serviceURL, successCallback, errorCallback);
}); });
} else { } else {
$(messageSideBar).html("<h4 class ='message-danger'>You are not authorized to view notifications</h4>"); $(messageSideBar).html("<h4 class ='message-danger text-center'>You are not authorized to view notifications</h4>");
} }
} }

Loading…
Cancel
Save