Make ?view=external on profile page require a login if the profile is not actually public

face-detect
Noah Petherbridge 2023-02-26 16:09:47 -08:00
parent 99e9ef9c7b
commit 1dc9afca5a
1 changed files with 15 additions and 14 deletions

View File

@ -30,20 +30,6 @@ func Profile() http.HandlerFunc {
return
}
// Forcing an external view? (preview of logged-out profile view for visibility=external accounts)
if r.FormValue("view") == "external" {
vars := map[string]interface{}{
"User": user,
"IsPrivate": true,
"IsExternalView": true,
}
if err := tmpl.Execute(w, r, vars); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
return
}
// Get the current user (if logged in). If not, check for external view.
currentUser, err := session.CurrentUser(r)
if err != nil {
@ -65,6 +51,21 @@ func Profile() http.HandlerFunc {
return
}
// Forcing an external view? (preview of logged-out profile view for visibility=external accounts)
// You must be logged-in actually to see this.
if r.FormValue("view") == "external" {
vars := map[string]interface{}{
"User": user,
"IsPrivate": true,
"IsExternalView": true,
}
if err := tmpl.Execute(w, r, vars); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
return
}
// Inject relationship booleans for profile picture display.
models.SetUserRelationships(currentUser, []*models.User{user})