import { AuthServiceConfig, AuthServiceI } from '@ioc:AuthService'; export default class AuthService implements AuthServiceI { private config; private client; private paths; constructor(config: AuthServiceConfig); createToken(sub: string): any; verifyToken(token: string, sub?: string): any; private setAuthToken; /** * isEnable is useful if enable both local or server auth * if true means you can use server auth else you can do something else * * Example code for login * * import User from 'App/Models/User' * import AuthService from '@ioc:AuthService' * public async login(ctx: HttpContextContract) { const { email, password } = ctx.request.only(['email', 'password']) try { let user: User | null, token: any = null, sso_url = null if (AuthService.isEnable) { const res = await AuthService.login(email, password) const data = res.data.user sso_url = res.data.sso_url user = await User.findBy('uuid', data.uuid) if (!user) user = await User.findBy('email', email) if (user) { data.isLocked = false user.merge(data) await user.save() } else { user = await User.create(data) } token = await ctx.auth.use('api').generate(user, { expiresIn: '12 hours' }) } else { token = await ctx.auth.use('api').attempt(email, password) user = ctx.auth.use('api').user! if (!ctx.auth.use('api').user) { return ctx.response.status(400).json({ message: 'Invalid credentials', token }) } await ctx.auth.user?.merge({ isLocked: false }).save() } if (user) return ctx.response.json({ ...user.serialize(), token, sso_url }) } catch (e) { this.logger.error(`Error login: ${e.message}`) } return ctx.response.status(400).json({ message: 'Invalid credentials' }) } */ get isEnable(): boolean; getApps(): Promise>; login(email: string, password: string): Promise>; signup(params: any): Promise>; getUser(uuid: string): Promise>; updateUser(uuid: string, params: any): Promise>; forgotPassword(email: string): Promise>; resendEmailVerification(email: string): Promise>; verifyPin(uuid: string, user_pin: string): Promise>; forgotPin(uuid: string, password: string, user_pin: string): Promise>; forgotPasswordMobile(params: any): Promise>; logoutURL(): string; checkLoginURL(): string; createRegisterWebAuthnChallenge(uuid: string, origin: string): Promise>; registerWebAuthnCredential(uuid: string, params: any): Promise>; createLoginWebAuthnChallenge(origin: string): Promise>; loginWithWebAuthnCredential(params: any): Promise>; deleteWebAuthnCredential(uuid: string, id: string): Promise>; listWebAuthnCredentials(uuid: string): Promise>; updateWebAuthnCredential(uuid: string, id: string, params: any): Promise>; getReferralSettings(): Promise>; getReferralProfile(uuid: string): Promise>; quoteReferral(params: any): Promise>; reserveReferral(params: any): Promise>; completeReferral(params: any): Promise>; releaseReferral(params: any): Promise>; }