-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow logging into unverified accounts
When the user logs in via an external provider, we can consider that proof of them owning the email account. In that case, we can automatically verify the account and proceed with the login.
- Loading branch information
Showing
4 changed files
with
72 additions
and
5 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 |
---|---|---|
|
@@ -66,7 +66,35 @@ | |
assert_equal 1, DB[:accounts].count | ||
end | ||
|
||
it "doesn't log in unverified accounts" do | ||
it "verifies unverified accounts by default" do | ||
DB[:accounts].delete | ||
|
||
rodauth do | ||
enable :omniauth, :verify_account | ||
omniauth_provider :developer | ||
create_account_set_password? true | ||
create_account_autologin? false | ||
end | ||
roda do |r| | ||
r.rodauth | ||
r.root do | ||
view content: "Verified: #{rodauth.account! && rodauth.open_account?}" | ||
end | ||
end | ||
|
||
visit "/create-account" | ||
fill_in "Login", with: "[email protected]" | ||
fill_in "Password", with: "secret" | ||
fill_in "Confirm Password", with: "secret" | ||
click_on "Create Account" | ||
assert_equal "An email has been sent to you with a link to verify your account", page.find("#notice_flash").text | ||
|
||
omniauth_login "/auth/developer" | ||
assert_equal "You have been logged in", page.find("#notice_flash").text | ||
assert_includes page.html, "Verified: true" | ||
end | ||
|
||
it "rejects unverified accounts if verify_account feature is not loaded" do | ||
DB[:accounts].update(status_id: 1) | ||
|
||
rodauth do | ||
|
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