**What** - Add authentication endpoints: - `/auth/[scope]/[provider]` - `/auth/[scope]/[provider]/callback` - update authenticate-middleware handler - Add scope field to user - Add unique constraint on scope and entity_id note: there's still some remaining work related to jwt auth to be handled, this is mainly focussed on session auth with endpoints Co-authored-by: Sebastian Rindom <7554214+srindom@users.noreply.github.com>
38 lines
747 B
TypeScript
38 lines
747 B
TypeScript
import { AuthUser } from "@models"
|
|
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
|
|
|
export async function createAuthUsers(
|
|
manager: SqlEntityManager,
|
|
userData: any[] = [
|
|
{
|
|
id: "test-id",
|
|
entity_id: "test-id",
|
|
provider: "manual",
|
|
scope: "store",
|
|
},
|
|
{
|
|
id: "test-id-1",
|
|
entity_id: "test-id-1",
|
|
provider: "manual",
|
|
scope: "store",
|
|
},
|
|
{
|
|
entity_id: "test-id-2",
|
|
provider: "store",
|
|
scope: "store",
|
|
},
|
|
]
|
|
): Promise<AuthUser[]> {
|
|
const authUsers: AuthUser[] = []
|
|
|
|
for (const user of userData) {
|
|
const authUser = manager.create(AuthUser, user)
|
|
|
|
authUsers.push(authUser)
|
|
}
|
|
|
|
await manager.persistAndFlush(authUsers)
|
|
|
|
return authUsers
|
|
}
|