-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9fad9f2
commit ce3266a
Showing
4 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
# ONLY AVAILABLE IN DEV MODE | ||
# This command will fail if server is not running in dev mode. | ||
if [[ ! -d .nitro ]]; then | ||
ln -s .nuxt .nitro | ||
fi | ||
|
||
if [ ! $# -eq 2 ] | ||
then | ||
echo "No arguments supplied" | ||
echo "Usage: bin/reset-pass.sh <email> <password>" | ||
else | ||
echo "Resetting password for $1" | ||
npx nitro task run chore:reset-pass --payload "{ \"email\": \"$1\", \"password\": \"$2\" }" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { eq } from 'drizzle-orm'; | ||
import { adminsTable } from '~~/server/db/schema'; | ||
|
||
export default defineTask({ | ||
meta: { | ||
name: 'chore:reset-pass', | ||
description: "Helps reset a user's password", | ||
}, | ||
async run({ payload }) { | ||
try { | ||
const db = await useDatabase(); | ||
|
||
const email = payload.email as string; | ||
const newPassword = payload.password as string; | ||
|
||
await db | ||
.update(adminsTable) | ||
.set({ | ||
password: await hashPassword(newPassword), | ||
}) | ||
.where(eq(adminsTable.email, email)); | ||
|
||
console.log(`chore:reset-pass success. ${new Date().toISOString()}`); | ||
return { result: true }; | ||
} catch (error) { | ||
console.error(`chore:reset-pass failed. ${new Date().toISOString()}`, error); | ||
return { result: false }; | ||
} | ||
}, | ||
}); |