Revamp the authentication setup (#7419)
* feat: Add email pass authentication provider package * feat: Revamp auth module and remove concept of scope * feat: Revamp the auth module to be more standardized in how providers are loaded * feat: Switch from scope to actor type for authentication * feat: Add support for per-actor auth methods * feat: Add emailpass auth provider by default * fix: Add back app_metadata in auth module
This commit is contained in:
@@ -10,13 +10,13 @@ export class Auth {
|
||||
this.config = config
|
||||
}
|
||||
|
||||
public login = async (
|
||||
scope: "admin" | "store",
|
||||
login = async (
|
||||
actor: "customer" | "user",
|
||||
method: "emailpass",
|
||||
payload: { email: string; password: string }
|
||||
) => {
|
||||
const { token } = await this.client.fetch<{ token: string }>(
|
||||
`/auth/${scope}/${method}`,
|
||||
`/auth/${actor}/${method}`,
|
||||
{
|
||||
method: "POST",
|
||||
body: payload,
|
||||
@@ -45,11 +45,11 @@ export class Auth {
|
||||
}
|
||||
|
||||
create = async (
|
||||
scope: "admin" | "store",
|
||||
actor: "customer" | "user",
|
||||
method: "emailpass",
|
||||
payload: { email: string; password: string }
|
||||
): Promise<{ token: string }> => {
|
||||
return await this.client.fetch(`/auth/${scope}/${method}`, {
|
||||
return await this.client.fetch(`/auth/${actor}/${method}`, {
|
||||
method: "POST",
|
||||
body: payload,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user