-
-
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.
Merge pull request #92 from Pomog/yurii_dev
Yurii dev
- Loading branch information
Showing
21 changed files
with
197 additions
and
32 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
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package handler | ||
|
||
import ( | ||
"net/http" | ||
"strconv" | ||
"strings" | ||
|
||
"github.com/Pomog/ForumFFF/internal/models" | ||
"github.com/Pomog/ForumFFF/internal/renderer" | ||
) | ||
|
||
// ChangeUserTypeResultHandler handles changing of user type | ||
func (m *Repository) ChangeUserTypeResultHandler(w http.ResponseWriter, r *http.Request) { | ||
sessionUserID := m.GetLoggedUser(w, r) | ||
if sessionUserID == 0 { | ||
setErrorAndRedirect(w, r, "unautorized", "/error-page") | ||
return | ||
} | ||
personalCabinetUserID, err := strconv.Atoi(r.URL.Query().Get("userID")) | ||
if err != nil { | ||
setErrorAndRedirect(w, r, "could not convert string to int: strconv.Atoi(r.URL.Query().Get(userID))", "/error-page") | ||
return | ||
} | ||
if sessionUserID != personalCabinetUserID { | ||
setErrorAndRedirect(w, r, "only owner of cabinet can submit secret code", "/error-page") | ||
return | ||
} | ||
inputPass := strings.TrimSpace(r.FormValue("changeUserType")) | ||
|
||
if r.Method == http.MethodPost && inputPass == m.App.ModeratorPass { | ||
user, _ := m.DB.GetUserByID(sessionUserID) | ||
user.Type = "moder" | ||
m.DB.EditUserType(user) | ||
|
||
data := make(map[string]interface{}) | ||
data["userID"] = user.ID | ||
renderer.RendererTemplate(w, "edit_user_type_result.page.html", &models.TemplateData{ | ||
Data: data, | ||
}) | ||
|
||
} else { | ||
http.Error(w, "wrong secret code", http.StatusMethodNotAllowed) | ||
} | ||
|
||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{{template "body" .}} | ||
|
||
{{define "centralPart"}} | ||
<div class="container custom-container"> | ||
{{$userID := index .Data "userID"}} | ||
<div class="mt-3"> | ||
<p>Congratulations! Your upgrade has been approved. You're now wielding the mighty powers | ||
of a Moderator! Time to sprinkle some stardust and wield that virtual hammer with grace. | ||
🌟 And hey, remember, with great power comes great... jokes! How about this one: Why don't | ||
programmers like nature? It has too many bugs! 😄 Welcome to the Moderator club, where puns | ||
and power collide!</p> | ||
<br><a href="/personal_cabinet?userID={{$userID}}"><h2>Return to your cabinet...</h2></a> | ||
</div> | ||
</div> | ||
|
||
{{end}} |
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.