Implemented actual authentication guards, began implementing main login user flows
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
// const pool = require('../db');
|
||||
import pool from '../db';
|
||||
|
||||
export interface CalendarEvent {
|
||||
|
||||
26
api/src/services/rolesService.ts
Normal file
26
api/src/services/rolesService.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import pool from '../db';
|
||||
|
||||
export async function assignUserGroup(userID: number, roleID: number) {
|
||||
|
||||
const sql = `INSERT INTO members_roles (member_id, role_id) VALUES (?, ?);`;
|
||||
const params = [userID, roleID];
|
||||
|
||||
return await pool.query(sql, params);
|
||||
}
|
||||
|
||||
export async function createGroup(name: string, color: string, description: string) {
|
||||
const sql = `INSERT INTO roles (name, color, description) VALUES (?, ?, ?)`;
|
||||
const params = [name, color, description];
|
||||
|
||||
const result = await pool.query(sql, params);
|
||||
return { id: result.insertId, name, color, description };
|
||||
}
|
||||
|
||||
export async function getUserRoles(userID: number) {
|
||||
const sql = `SELECT r.id, r.name
|
||||
FROM members_roles mr
|
||||
INNER JOIN roles r ON mr.role_id = r.id
|
||||
WHERE mr.member_id = 190;`;
|
||||
|
||||
return await pool.query(sql, [userID]);
|
||||
}
|
||||
Reference in New Issue
Block a user