Restructure login endpoint changes to include account's admin status
This commit is contained in:
parent
a7d7c019e5
commit
d962bfc01e
3 changed files with 8 additions and 7 deletions
|
|
@ -82,7 +82,7 @@
|
|||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<i>Group ID: {{group.id}}</i>
|
||||
<i v-if="admin">Group ID: {{group.id}}</i>
|
||||
<hr>
|
||||
<div class="lurk-messages group-messages">
|
||||
<h4>Lurk Messages</h4>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
const app = new Vue({
|
||||
el: `#app`,
|
||||
data() {return {
|
||||
url: `https://vps.oliver.akins.me/lurk-api`,
|
||||
authenticated: false,
|
||||
channels: [],
|
||||
channel: ``,
|
||||
|
|
@ -12,21 +11,22 @@ const app = new Vue({
|
|||
api: null,
|
||||
messages: [],
|
||||
new_group: false,
|
||||
admin: false,
|
||||
}},
|
||||
methods: {
|
||||
async tryLogin() {
|
||||
try {
|
||||
let r = await axios.post(
|
||||
`${this.url}/login`,
|
||||
`/login`,
|
||||
undefined,
|
||||
{ auth: this.login }
|
||||
);
|
||||
this.api = axios.create({
|
||||
baseURL: this.url,
|
||||
validateStatus: null,
|
||||
auth: this.login,
|
||||
});
|
||||
this.channels.push(...r.data.sort());
|
||||
this.admin = r.data.admin;
|
||||
this.channels.push(...r.data.channels.sort());
|
||||
this.authenticated = true;
|
||||
} catch (_) {};
|
||||
},
|
||||
|
|
|
|||
|
|
@ -3,15 +3,16 @@ import { db } from "@/main";
|
|||
|
||||
const data: ServerRoute = {
|
||||
method: `POST`, path: `/login`,
|
||||
options: {},
|
||||
async handler(request, h) {
|
||||
const { access } = request.auth.credentials as { username: string, access: string[] };
|
||||
const { access, admin } = request.auth.credentials as { username: string, access: string[]; admin: boolean };
|
||||
|
||||
let channels = access.filter(x => x != "*");
|
||||
if (access.includes(`*`)) {
|
||||
channels.push(...Object.keys(db).filter(c => !channels.includes(c)));
|
||||
};
|
||||
|
||||
return h.response(channels).code(200);
|
||||
return h.response({ admin, channels }).code(200);
|
||||
},
|
||||
};
|
||||
export default data;
|
||||
Loading…
Add table
Add a link
Reference in a new issue