@adonisjs/ally
Version:
Social authentication provider for AdonisJS
45 lines (43 loc) • 1.11 kB
JavaScript
import {
AllyManager
} from "../chunk-ISWHUP4Q.js";
import "../chunk-TSIMPJ6I.js";
// providers/ally_provider.ts
import { configProvider } from "@adonisjs/core";
import { HttpContext } from "@adonisjs/core/http";
import { RuntimeException } from "@adonisjs/core/exceptions";
var AllyProvider = class {
/**
* Create a new Ally provider instance.
*
* @param app - The AdonisJS application service.
*/
constructor(app) {
this.app = app;
}
app;
/**
* Boot the provider and register the `ctx.ally` getter.
*
* @returns A promise that resolves once the provider has been booted.
*/
async boot() {
const allyConfigProvider = this.app.config.get("ally");
const config = await configProvider.resolve(this.app, allyConfigProvider);
if (!config) {
throw new RuntimeException(
'Invalid "config/ally.ts" file. Make sure you are using the "defineConfig" method'
);
}
HttpContext.getter(
"ally",
function() {
return new AllyManager(config, this);
},
true
);
}
};
export {
AllyProvider as default
};