Skip to content

Commit

Permalink
reimpl login w/ password and signup
Browse files Browse the repository at this point in the history
  • Loading branch information
dromzeh committed Dec 8, 2023
1 parent dfee95b commit 658a58c
Show file tree
Hide file tree
Showing 6 changed files with 1,919 additions and 2,138 deletions.
29 changes: 25 additions & 4 deletions src/scripts/seed/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ import {
userCollectionAsset,
userFavoriteAsset,
userFavorite,
authCredentials,
} from "@/v2/db/schema"
import { generateID } from "@/v2/lib/oslo"
import { Scrypt } from "oslo/password"

const { ENVIRONMENT } = process.env

Expand Down Expand Up @@ -46,8 +48,8 @@ async function main() {
.values([
{
id: generateID(),
username: "testuser",
email: "[email protected]",
username: "adminuser",
email: "[email protected]",
emailVerified: 1,
usernameColour: "#84E6F8",
bio: "test bio",
Expand All @@ -58,7 +60,7 @@ async function main() {
{
id: generateID(),
username: "testuser2",
email: "hi2@dromzeh.dev",
email: "testuser2@dromzeh.dev",
emailVerified: 1,
bio: "test bio 2",
pronouns: "he/him/his",
Expand All @@ -69,7 +71,7 @@ async function main() {
{
id: generateID(),
username: "testuser3",
email: "[email protected]",
email: "[email protected]",
emailVerified: 1,
bio: "test bio 3",
roleFlags: 1,
Expand All @@ -80,6 +82,25 @@ async function main() {
.returning()
console.log(`[SEED] [authUser] inserted ${newUsers.length} rows\n`)

const devAdminPassword = generateID(12)

console.log(
`[SEED] [userCredentials] Seeding user login for admin with password ${devAdminPassword}...`
)

const newCredentials = await db
.insert(authCredentials)
.values({
id: generateID(20),
userId: newUsers[0].id,
hashedPassword: await new Scrypt().hash(devAdminPassword),
})
.returning()

console.log(
`[SEED] [userCredentials] inserted ${newCredentials.length} rows\n`
)

console.log("[SEED] [userFollowing] Seeding user following...")
const newuserFollowing = await db
.insert(userFollowing)
Expand Down
Loading

0 comments on commit 658a58c

Please sign in to comment.