mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-24 05:05:20 -04:00
CR & lint fixes
This commit is contained in:
parent
866a6b5923
commit
899aac28ee
@ -165,7 +165,7 @@
|
||||
</nuxt-link>
|
||||
<div class="list-group-item pt-3">
|
||||
<h6>
|
||||
<Icon v="key"/> Authenticators
|
||||
<Icon v="key" /> Authenticators
|
||||
</h6>
|
||||
<Loading :value="authenticators">
|
||||
<p>
|
||||
@ -175,10 +175,12 @@
|
||||
</p>
|
||||
<ul>
|
||||
<template v-for="authenticator in authenticators">
|
||||
<li v-if="showExpiredAuthenticators || authenticator.validUntil === null"
|
||||
:class="authenticator.validUntil === null ? '' : 'small text-muted'">
|
||||
<li
|
||||
v-if="showExpiredAuthenticators || authenticator.validUntil === null"
|
||||
:class="authenticator.validUntil === null ? '' : 'small text-muted'"
|
||||
>
|
||||
<Tooltip :text="authenticator.type">
|
||||
<Icon :v="authenticatorIcon(authenticator.type)"/>
|
||||
<Icon :v="authenticatorIcon(authenticator.type)" />
|
||||
</Tooltip>
|
||||
{{ $datetime($ulidTime(authenticator.id)) }}
|
||||
<pre><code>{{ authenticator.payload }}</code></pre>
|
||||
@ -440,10 +442,10 @@ export default mainPronoun.extend({
|
||||
case 'mfa_recovery':
|
||||
return 'mobile';
|
||||
default:
|
||||
return 'b:' + type;
|
||||
}
|
||||
return `b:${type}`;
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Router } from 'express';
|
||||
import SQL from 'sql-template-strings';
|
||||
import avatar from '../avatar.ts';
|
||||
import {buildDict, now, shuffle, handleErrorAsync, filterObjectKeys} from '../../src/helpers.ts';
|
||||
import { buildDict, now, shuffle, handleErrorAsync, filterObjectKeys } from '../../src/helpers.ts';
|
||||
import allLocales from '../../locale/locales.ts';
|
||||
import fs from 'fs';
|
||||
import { caches } from '../../src/cache.js';
|
||||
@ -666,16 +666,16 @@ router.get('/admin/authenticators/:id', handleErrorAsync(async (req, res) => {
|
||||
SELECT * FROM authenticators
|
||||
WHERE userId = ${req.params.id}
|
||||
ORDER BY id DESC
|
||||
`)).map(auth => {
|
||||
`)).map((auth) => {
|
||||
delete auth.userId;
|
||||
|
||||
let payload = JSON.parse(auth.payload);
|
||||
auth.payload = typeof(payload) === 'string'
|
||||
const payload = JSON.parse(auth.payload);
|
||||
auth.payload = typeof payload === 'string'
|
||||
? null
|
||||
: filterObjectKeys(payload, ['id', 'email', 'name', 'instance', 'username']);
|
||||
|
||||
return auth;
|
||||
})
|
||||
});
|
||||
|
||||
return res.json(authenticators);
|
||||
}));
|
||||
|
@ -503,11 +503,11 @@ export const parseUserJwt = (token: string): string | JwtPayload | null => {
|
||||
}
|
||||
};
|
||||
|
||||
export const filterObjectKeys = (obj: Record<string, any>, keysToKeep: Array<string>) => {
|
||||
return Object.keys(obj).reduce((filteredObj: Record<string, any>, key) => {
|
||||
if (keysToKeep.includes(key)) {
|
||||
export const filterObjectKeys = <T extends Record<string, any>, K extends keyof T>(obj: T, keysToKeep: K[]): Pick<T, K> => {
|
||||
return keysToKeep.reduce((filteredObj, key) => {
|
||||
if (key in obj) {
|
||||
filteredObj[key] = obj[key];
|
||||
}
|
||||
return filteredObj;
|
||||
}, {});
|
||||
}
|
||||
}, {} as Pick<T, K>);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user