Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
62528ac1
Commit
62528ac1
authored
10 years ago
by
Cam Saul
Browse files
Options
Downloads
Patches
Plain Diff
Send password reset email
parent
337a2839
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/metabase/api/session.clj
+16
-5
16 additions, 5 deletions
src/metabase/api/session.clj
with
16 additions
and
5 deletions
src/metabase/api/session.clj
+
16
−
5
View file @
62528ac1
...
...
@@ -6,6 +6,7 @@
[
korma.core
:as
korma
]
[
metabase.api.common
:refer
:all
]
[
metabase.db
:refer
:all
]
[
metabase.email
:as
email
]
(
metabase.models
[
user
:refer
[
User
set-user-password
]]
[
session
:refer
[
Session
]])))
...
...
@@ -30,14 +31,24 @@
;; forgotten password reset email
(
defendpoint
POST
"/forgot_password"
[
:as
{{
:keys
[
email
]
:as
body
}
:body
}]
(
defendpoint
POST
"/forgot_password"
[
:as
{{
:keys
[
email
]}
:body,
{
:strs
[
origin
]}
:headers
}]
;; Use the `origin` header, which looks like `http://localhost:3000`, as the base of the reset password URL.
;; (Currently, there's no other way to get this info)
;;
;; This is a bit sketchy. Someone malicious could send a bad origin header and hit this endpoint to send
;; a forgotten password email to another User, and take them to some sort of phishing site. Although not sure
;; what you could phish from them since they already forgot their password.
(
require-params
email
)
(
let
[
user-id
(
sel
:one
:id
User
:email
email
)
reset-token
(
java.util.UUID/randomUUID
)]
(
let
[{
user-id
:id
user-name
:common_name
}
(
sel
:one
User
:email
email
)
reset-token
(
java.util.UUID/randomUUID
)
password-reset-url
(
str
origin
"/auth/reset_password/"
reset-token
)]
(
check-404
user-id
)
(
upd
User
user-id
:reset_token
reset-token
:reset_triggered
(
System/currentTimeMillis
))
;; TODO - send email
(
log/info
(
str
"/auth/reset_password/"
reset-token
))))
(
email/send-message
"Metabase Password Reset"
{
email
user-name
}
:html
(
format
"Hey %s, sorry you forgot your password :'(<br /><br /><a href=\"%s\">Click here to reset it!</a> <3"
user-name
password-reset-url
))
(
log/info
password-reset-url
)))
;; set password from reset token
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment