Fix page with lint errors #16
@@ -1,10 +1,9 @@
|
|||||||
import { createClient, type GenericCtx } from "@convex-dev/better-auth";
|
import { createClient, type GenericCtx } from '@convex-dev/better-auth';
|
||||||
import { convex } from "@convex-dev/better-auth/plugins";
|
import { convex } from '@convex-dev/better-auth/plugins';
|
||||||
import { components } from "./_generated/api";
|
import { components } from './_generated/api';
|
||||||
import { type DataModel } from "./_generated/dataModel";
|
import { type DataModel } from './_generated/dataModel';
|
||||||
import { mutation, MutationCtx, query, QueryCtx } from "./_generated/server";
|
import { MutationCtx, query, QueryCtx } from './_generated/server';
|
||||||
import { betterAuth } from "better-auth";
|
import { betterAuth } from 'better-auth';
|
||||||
import { v } from "convex/values";
|
|
||||||
|
|
||||||
const siteUrl = process.env.SITE_URL!;
|
const siteUrl = process.env.SITE_URL!;
|
||||||
|
|
||||||
@@ -20,19 +19,19 @@ export const createAuth = (
|
|||||||
// disable logging when createAuth is called just to generate options.
|
// disable logging when createAuth is called just to generate options.
|
||||||
// this is not required, but there's a lot of noise in logs without it.
|
// this is not required, but there's a lot of noise in logs without it.
|
||||||
logger: {
|
logger: {
|
||||||
disabled: optionsOnly,
|
disabled: optionsOnly
|
||||||
},
|
},
|
||||||
baseURL: siteUrl,
|
baseURL: siteUrl,
|
||||||
database: authComponent.adapter(ctx),
|
database: authComponent.adapter(ctx),
|
||||||
// Configure simple, non-verified email/password to get started
|
// Configure simple, non-verified email/password to get started
|
||||||
emailAndPassword: {
|
emailAndPassword: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
requireEmailVerification: false,
|
requireEmailVerification: false
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
// The Convex plugin is required for Convex compatibility
|
// The Convex plugin is required for Convex compatibility
|
||||||
convex(),
|
convex()
|
||||||
],
|
]
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -47,25 +46,27 @@ export const getCurrentUser = query({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const user = await ctx.db
|
const user = await ctx.db
|
||||||
.query("usuarios")
|
.query('usuarios')
|
||||||
.withIndex("authId", (q) => q.eq("authId", authUser._id))
|
.withIndex('authId', (q) => q.eq('authId', authUser._id))
|
||||||
.unique();
|
.unique();
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const fotoPerfilUrl = user.fotoPerfil ? await ctx.storage.getUrl(user.fotoPerfil) : null;
|
||||||
|
|
||||||
if (!user.roleId) {
|
if (!user.roleId) {
|
||||||
return { ...user, role: null };
|
return { ...user, role: null, fotoPerfilUrl };
|
||||||
}
|
}
|
||||||
|
|
||||||
const role = await ctx.db
|
const role = await ctx.db
|
||||||
.query("roles")
|
.query('roles')
|
||||||
.withIndex("by_id", (q) => q.eq("_id", user.roleId))
|
.withIndex('by_id', (q) => q.eq('_id', user.roleId))
|
||||||
.unique();
|
.unique();
|
||||||
|
|
||||||
return { ...user, role };
|
return { ...user, role, fotoPerfilUrl };
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export const getCurrentUserFunction = async (ctx: QueryCtx | MutationCtx) => {
|
export const getCurrentUserFunction = async (ctx: QueryCtx | MutationCtx) => {
|
||||||
@@ -75,8 +76,8 @@ export const getCurrentUserFunction = async (ctx: QueryCtx | MutationCtx) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const user = await ctx.db
|
const user = await ctx.db
|
||||||
.query("usuarios")
|
.query('usuarios')
|
||||||
.withIndex("authId", (q) => q.eq("authId", authUser._id))
|
.withIndex('authId', (q) => q.eq('authId', authUser._id))
|
||||||
.unique();
|
.unique();
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return;
|
return;
|
||||||
@@ -95,8 +96,8 @@ export const createAuthUser = async (
|
|||||||
body: {
|
body: {
|
||||||
name: args.nome,
|
name: args.nome,
|
||||||
email: args.email,
|
email: args.email,
|
||||||
password: args.password,
|
password: args.password
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return result.user.id;
|
return result.user.id;
|
||||||
@@ -112,7 +113,7 @@ export const updatePassword = async (
|
|||||||
headers,
|
headers,
|
||||||
body: {
|
body: {
|
||||||
currentPassword: args.currentPassword,
|
currentPassword: args.currentPassword,
|
||||||
newPassword: args.newPassword,
|
newPassword: args.newPassword
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user