@stacksjs/auth 0.62.0 → 0.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +71458 -157856
- package/dist/index.js.map +1204 -0
- package/package.json +2 -2
- package/src/authentication.ts +11 -7
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/auth",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.63.0",
|
|
5
5
|
"description": "A more simplistic way to authenticate.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"license": "MIT",
|
|
@@ -52,6 +52,6 @@
|
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@stacksjs/router": "latest",
|
|
54
54
|
"otplib": "^12.0.1",
|
|
55
|
-
"qrcode": "^1.5.
|
|
55
|
+
"qrcode": "^1.5.4"
|
|
56
56
|
}
|
|
57
57
|
}
|
package/src/authentication.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { request } from '@stacksjs/router'
|
|
2
|
+
import { verifyHash } from '@stacksjs/security'
|
|
2
3
|
import AccessToken from '../../../orm/src/models/AccessToken'
|
|
3
4
|
import Team from '../../../orm/src/models/Team'
|
|
4
5
|
import User from '../../../orm/src/models/User'
|
|
@@ -13,14 +14,16 @@ const authConfig = { username: 'email', password: 'password' }
|
|
|
13
14
|
let authUser: any = undefined
|
|
14
15
|
|
|
15
16
|
export async function attempt(credentials: Credentials, remember?: boolean) {
|
|
16
|
-
const user = await User.where(authConfig.username, credentials[authConfig.username])
|
|
17
|
-
.where(authConfig.password, credentials[authConfig.password])
|
|
18
|
-
.first()
|
|
17
|
+
const user = await User.where(authConfig.username, credentials[authConfig.username]).first()
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
authUser = user
|
|
19
|
+
const hashCheck = await verifyHash(credentials[authConfig.password], user?.password, 'bcrypt')
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
if (hashCheck) {
|
|
22
|
+
if (user) {
|
|
23
|
+
authUser = user
|
|
24
|
+
|
|
25
|
+
return true
|
|
26
|
+
}
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
return false
|
|
@@ -68,7 +71,8 @@ export async function authToken() {
|
|
|
68
71
|
|
|
69
72
|
const team = teams[0]
|
|
70
73
|
|
|
71
|
-
const
|
|
74
|
+
const accessTokens = await team.teamAccessTokens()
|
|
75
|
+
const accessToken = accessTokens[0]
|
|
72
76
|
|
|
73
77
|
const tokenId = accessToken?.id
|
|
74
78
|
|