forked from pocketbase/pocketbase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added onlyVerified auth collection option
- Loading branch information
1 parent
865865f
commit 31317df
Showing
43 changed files
with
573 additions
and
428 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
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 |
---|---|---|
|
@@ -212,7 +212,7 @@ func TestRecordAuthWithPassword(t *testing.T) { | |
}, | ||
}, | ||
{ | ||
Name: "valid email and valid password in allowed collection", | ||
Name: "valid email (unverified) and valid password in allowed collection", | ||
Method: http.MethodPost, | ||
Url: "/api/collections/users/auth-with-password", | ||
Body: strings.NewReader(`{ | ||
|
@@ -225,6 +225,48 @@ func TestRecordAuthWithPassword(t *testing.T) { | |
`"token":"`, | ||
`"id":"4q1xlclmfloku33"`, | ||
`"email":"[email protected]"`, | ||
`"verified":false`, | ||
}, | ||
ExpectedEvents: map[string]int{ | ||
"OnRecordBeforeAuthWithPasswordRequest": 1, | ||
"OnRecordAfterAuthWithPasswordRequest": 1, | ||
"OnRecordAuthRequest": 1, | ||
}, | ||
}, | ||
|
||
// onlyVerified collection check | ||
{ | ||
Name: "unverified user in onlyVerified collection", | ||
Method: http.MethodPost, | ||
Url: "/api/collections/clients/auth-with-password", | ||
Body: strings.NewReader(`{ | ||
"identity":"[email protected]", | ||
"password":"1234567890" | ||
}`), | ||
ExpectedStatus: 403, | ||
ExpectedContent: []string{ | ||
`"data":{}`, | ||
}, | ||
ExpectedEvents: map[string]int{ | ||
"OnRecordBeforeAuthWithPasswordRequest": 1, | ||
"OnRecordAfterAuthWithPasswordRequest": 1, | ||
}, | ||
}, | ||
{ | ||
Name: "verified user in onlyVerified collection", | ||
Method: http.MethodPost, | ||
Url: "/api/collections/clients/auth-with-password", | ||
Body: strings.NewReader(`{ | ||
"identity":"[email protected]", | ||
"password":"1234567890" | ||
}`), | ||
ExpectedStatus: 200, | ||
ExpectedContent: []string{ | ||
`"record":{`, | ||
`"token":"`, | ||
`"id":"gk390qegs4y47wn"`, | ||
`"email":"[email protected]"`, | ||
`"verified":true`, | ||
}, | ||
ExpectedEvents: map[string]int{ | ||
"OnRecordBeforeAuthWithPasswordRequest": 1, | ||
|
@@ -377,6 +419,41 @@ func TestRecordAuthRefresh(t *testing.T) { | |
"OnRecordAfterAuthRefreshRequest": 1, | ||
}, | ||
}, | ||
{ | ||
Name: "unverified auth record in onlyVerified collection", | ||
Method: http.MethodPost, | ||
Url: "/api/collections/clients/auth-refresh", | ||
RequestHeaders: map[string]string{ | ||
"Authorization": "eyJhbGciOiJIUzI1NiJ9.eyJpZCI6Im8xeTBkZDBzcGQ3ODZtZCIsInR5cGUiOiJhdXRoUmVjb3JkIiwiY29sbGVjdGlvbklkIjoidjg1MXE0cjc5MHJoa25sIiwiZXhwIjoyMjA4OTg1MjYxfQ.-JYlrz5DcGzvb0nYx-xqnSFMu9dupyKY7Vg_FUm0OaM", | ||
}, | ||
ExpectedStatus: 403, | ||
ExpectedContent: []string{`"data":{}`}, | ||
ExpectedEvents: map[string]int{ | ||
"OnRecordBeforeAuthRefreshRequest": 1, | ||
"OnRecordAfterAuthRefreshRequest": 1, | ||
}, | ||
}, | ||
{ | ||
Name: "verified auth record in onlyVerified collection", | ||
Method: http.MethodPost, | ||
Url: "/api/collections/clients/auth-refresh", | ||
RequestHeaders: map[string]string{ | ||
"Authorization": "eyJhbGciOiJIUzI1NiJ9.eyJpZCI6ImdrMzkwcWVnczR5NDd3biIsInR5cGUiOiJhdXRoUmVjb3JkIiwiY29sbGVjdGlvbklkIjoidjg1MXE0cjc5MHJoa25sIiwiZXhwIjoyMjA4OTg1MjYxfQ.q34IWXrRWsjLvbbVNRfAs_J4SoTHloNBfdGEiLmy-D8", | ||
}, | ||
ExpectedStatus: 200, | ||
ExpectedContent: []string{ | ||
`"token":`, | ||
`"record":`, | ||
`"id":"gk390qegs4y47wn"`, | ||
`"verified":true`, | ||
`"email":"[email protected]"`, | ||
}, | ||
ExpectedEvents: map[string]int{ | ||
"OnRecordBeforeAuthRefreshRequest": 1, | ||
"OnRecordAuthRequest": 1, | ||
"OnRecordAfterAuthRefreshRequest": 1, | ||
}, | ||
}, | ||
{ | ||
Name: "OnRecordAfterAuthRefreshRequest error response", | ||
Method: http.MethodPost, | ||
|
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
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
Oops, something went wrong.