mirror of
https://github.com/nasa/openmct.git
synced 2025-03-15 00:36:33 +00:00
Add session storage and role to user indicator
This commit is contained in:
parent
f5d57210ae
commit
6a9b9613e4
37
src/api/user/SessionPersistance.js
Normal file
37
src/api/user/SessionPersistance.js
Normal file
@ -0,0 +1,37 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2023, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed 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.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
import { SESSION_STORAGE_KEY } from './constants';
|
||||
|
||||
export default {
|
||||
getActiveRole() {
|
||||
return sessionStorage.getItem(SESSION_STORAGE_KEY);
|
||||
},
|
||||
|
||||
setActiveRole(role) {
|
||||
return sessionStorage.setItem(SESSION_STORAGE_KEY, role);
|
||||
},
|
||||
|
||||
clearActiveRole() {
|
||||
return sessionStorage.removeItem(SESSION_STORAGE_KEY);
|
||||
}
|
||||
};
|
@ -22,3 +22,5 @@
|
||||
|
||||
export const MULTIPLE_PROVIDER_ERROR = 'Only one user provider may be set at a time.';
|
||||
export const NO_PROVIDER_ERROR = 'No user provider has been set.';
|
||||
|
||||
export const SESSION_STORAGE_KEY = 'USER_ROLE';
|
||||
|
@ -23,7 +23,8 @@
|
||||
<template>
|
||||
<div class="c-indicator icon-person c-indicator--clickable">
|
||||
<span class="label c-indicator__label">
|
||||
{{ userName }}
|
||||
{{ `${userName}: ${role}` }}
|
||||
<button>Change Role</button>
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
@ -35,6 +36,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
userName: undefined,
|
||||
role: undefined,
|
||||
loggedIn: false
|
||||
};
|
||||
},
|
||||
@ -46,6 +48,7 @@ export default {
|
||||
getUserInfo() {
|
||||
this.openmct.user.getCurrentUser().then((user) => {
|
||||
this.userName = user.getName();
|
||||
this.role = user.getRole();
|
||||
this.loggedIn = this.openmct.user.isLoggedIn();
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user