mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-22 09:00:10 +00:00
userpage: make pwr accept username too
This commit is contained in:
parent
3ec3e9672e
commit
22c91be127
@ -478,7 +478,7 @@ func (app *appContext) UnlinkMyMatrix(gc *gin.Context) {
|
|||||||
respondBool(200, true, gc)
|
respondBool(200, true, gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Summary Generate & send a password reset link if the given email/contact method exists. Doesn't give you any info about it's success.
|
// @Summary Generate & send a password reset link if the given username/email/contact method exists. Doesn't give you any info about it's success.
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param address path string true "address/contact method associated w/ your account."
|
// @Param address path string true "address/contact method associated w/ your account."
|
||||||
// @Success 204 {object} boolResponse
|
// @Success 204 {object} boolResponse
|
||||||
@ -502,7 +502,7 @@ func (app *appContext) ResetMyPassword(gc *gin.Context) {
|
|||||||
var pwr InternalPWR
|
var pwr InternalPWR
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
jfID := app.reverseUserSearch(address)
|
jfID := app.ReverseUserSearch(address)
|
||||||
if jfID == "" {
|
if jfID == "" {
|
||||||
app.debug.Printf("Ignoring PWR request: User not found")
|
app.debug.Printf("Ignoring PWR request: User not found")
|
||||||
|
|
||||||
|
@ -377,7 +377,7 @@
|
|||||||
"order": [],
|
"order": [],
|
||||||
"meta": {
|
"meta": {
|
||||||
"name": "User Page",
|
"name": "User Page",
|
||||||
"description": "Settings for the user page, which provides useful info and tools to users directly.",
|
"description": "The User Page (My Account) allows users to access and modify info directly, such as changing/adding contact methods, seeing their expiry date, or changing their password. Password resets can also be initiated from here, given a contact method or username. ",
|
||||||
"depends_true": "ui|jellyfin_login"
|
"depends_true": "ui|jellyfin_login"
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
|
8
email.go
8
email.go
@ -872,7 +872,13 @@ func (app *appContext) getAddressOrName(jfID string) string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *appContext) reverseUserSearch(address string) string {
|
// ReverseUserSearch returns the jellyfin ID of the user with the given username, email, or contact method username.
|
||||||
|
// returns "" if none found. returns only the first match, might be an issue if there are users with the same contact method usernames.
|
||||||
|
func (app *appContext) ReverseUserSearch(address string) string {
|
||||||
|
user, status, err := app.jf.UserByName(address, false)
|
||||||
|
if status == 200 && err == nil {
|
||||||
|
return user.ID
|
||||||
|
}
|
||||||
for id, email := range app.storage.GetEmails() {
|
for id, email := range app.storage.GetEmails() {
|
||||||
if strings.ToLower(address) == strings.ToLower(email.Addr) {
|
if strings.ToLower(address) == strings.ToLower(email.Addr) {
|
||||||
return id
|
return id
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
</p>
|
</p>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<input type="text" class="col sm field ~neutral @low input" id="pwr-address" placeholder="example@example.com | user#1234 | @user:host | @username">
|
<input type="text" class="col sm field ~neutral @low input" id="pwr-address" placeholder="username | example@example.com | user#1234 | @user:host | @username">
|
||||||
</div>
|
</div>
|
||||||
{{ if .linkResetEnabled }}
|
{{ if .linkResetEnabled }}
|
||||||
<span class="button ~info @low full-width center mt-4" id="pwr-submit">
|
<span class="button ~info @low full-width center mt-4" id="pwr-submit">
|
||||||
|
@ -29,9 +29,9 @@
|
|||||||
"userPageSuccessMessage": "You can see and change details about your account later on the {myAccount} page.",
|
"userPageSuccessMessage": "You can see and change details about your account later on the {myAccount} page.",
|
||||||
"resetPassword": "Reset Password",
|
"resetPassword": "Reset Password",
|
||||||
"resetPasswordThroughJellyfin": "To reset your password, visit {jfLink} and press the \"Forgot Password\" button.",
|
"resetPasswordThroughJellyfin": "To reset your password, visit {jfLink} and press the \"Forgot Password\" button.",
|
||||||
"resetPasswordThroughLink": "To reset your password, enter your email address or a linked contact method username, and submit. A link will be sent to reset your password.",
|
"resetPasswordThroughLink": "To reset your password, enter your username, email address or a linked contact method username, and submit. A link will be sent to reset your password.",
|
||||||
"resetSent": "Reset Sent.",
|
"resetSent": "Reset Sent.",
|
||||||
"resetSentDescription": "If an account with the given contact method exists, a password reset link has been sent to all contact methods available. The code will expire in 30 minutes."
|
"resetSentDescription": "If an account with the given username/contact method exists, a password reset link has been sent via all contact methods available. The code will expire in 30 minutes."
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"errorUserExists": "User already exists.",
|
"errorUserExists": "User already exists.",
|
||||||
|
Loading…
Reference in New Issue
Block a user