Browse Source

#9 - show app password use date in profile

master
Garrett Mills 1 month ago
parent
commit
cf91063315
  1. 6
      app/assets/app/dash/profile/EditProfile.component.js
  2. 1
      app/controllers/api/v1/Password.controller.js
  3. 1
      app/models/auth/AppPassword.model.js
  4. 6
      app/models/auth/User.model.js
  5. 1
      locale/en_US/common.locale.js
  6. 1
      locale/en_US/profile.locale.js

6
app/assets/app/dash/profile/EditProfile.component.js

@ -131,6 +131,7 @@ const template = `
<div class="col-9">
{{ pw.name }}
<br><span class="text-muted font-italic">{{ t['profile.issued'] }} {{ pw.created }}</span>
<span class="text-muted font-italic">&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;{{ t['profile.accessed'] }} {{ pw.accessed || t['common.never'] }}</span>
</div>
<div class="col-3 my-auto">
<button
@ -288,7 +289,9 @@ export default class EditProfileComponent extends Component {
'profile.save_notify',
'profile.test_notify',
'profile.advanced_header',
'profile.advanced_shell'
'profile.advanced_shell',
'profile.accessed',
'common.never'
)
this.app_name = session.get('app.name')
@ -403,6 +406,7 @@ export default class EditProfileComponent extends Component {
this.app_passwords = app_pws.map(x => {
if ( x.expires ) x.expires = (new Date(x.expires)).toLocaleDateString()
if ( x.created ) x.created = (new Date(x.created)).toLocaleDateString()
if ( x.accessed ) x.accessed = (new Date(x.accessed)).toLocaleDateString()
return x
})
}

1
app/controllers/api/v1/Password.controller.js

@ -20,6 +20,7 @@ class PasswordController extends Controller {
return {
created: x.created,
expires: x.expires,
accessed: x.accessed,
active: x.active,
name: x.name ?? req.T('common.unnamed'),
uuid: x.uuid,

1
app/models/auth/AppPassword.model.js

@ -7,6 +7,7 @@ class AppPasswordModel extends Model {
return {
hash: String,
created: { type: Date, default: () => new Date },
accessed: Date,
expires: Date,
active: { type: Boolean, default: true },
name: String,

6
app/models/auth/User.model.js

@ -160,7 +160,11 @@ class User extends AuthUser {
async check_app_password(password) {
for ( const pw of this.app_passwords ) {
if ( await pw.verify(password) ) return true
if ( await pw.verify(password) ) {
pw.accessed = new Date
await pw.save()
return true
}
}
return false

1
locale/en_US/common.locale.js

@ -7,6 +7,7 @@ module.exports = exports = {
invalid: 'Invalid',
unnamed: '(unnamed)',
never: 'Never',
yes: 'Yes',
no: 'No',

1
locale/en_US/profile.locale.js

@ -37,6 +37,7 @@ module.exports = exports = {
test_notification: 'This is a test notification! If you see this, it means you have properly configured your notification settings.',
issued: 'Issued:',
accessed: 'Last Used:',
gen_new: 'Generate New',
recovery_codes: 'Recovery Codes',
recovery_1: 'Recovery codes can be used to regain access to your account in the event that you lose access to the device that generates your MFA codes.',

Loading…
Cancel
Save