Added signup page.
This commit is contained in:
12
src/users.js
12
src/users.js
@@ -23,7 +23,7 @@ export function curateUser(user) {
|
||||
return curatedUser;
|
||||
}
|
||||
|
||||
export async function fetchUser(userId, raw) {
|
||||
export async function fetchUser(userId, options = {}) {
|
||||
const user = await knex('users')
|
||||
.select(knex.raw('users.*, users_roles.abilities as role_abilities, COALESCE(json_agg(stashes ORDER BY stashes.created_at) FILTER (WHERE stashes.id IS NOT NULL), \'[]\') as stashes'))
|
||||
.modify((builder) => {
|
||||
@@ -32,9 +32,11 @@ export async function fetchUser(userId, raw) {
|
||||
}
|
||||
|
||||
if (typeof userId === 'string') {
|
||||
builder
|
||||
.where('users.username', userId)
|
||||
.orWhere('users.email', userId);
|
||||
builder.where(knex.raw('lower(users.username)'), userId.toLowerCase());
|
||||
|
||||
if (options.email) {
|
||||
builder.orWhere(knex.raw('lower(users.email)'), userId.toLowerCase());
|
||||
}
|
||||
}
|
||||
})
|
||||
.leftJoin('users_roles', 'users_roles.role', 'users.role')
|
||||
@@ -42,7 +44,7 @@ export async function fetchUser(userId, raw) {
|
||||
.groupBy('users.id', 'users_roles.role')
|
||||
.first();
|
||||
|
||||
if (raw) {
|
||||
if (options.raw) {
|
||||
return user;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user