Compare commits
2 Commits
acea949eb7
...
095c3123ab
Author | SHA1 | Date |
---|---|---|
Jill | 095c3123ab | |
Jill | e18157d418 |
|
@ -91,7 +91,7 @@
|
|||
<a href="/"><img src="/favicon.png" width="64" height="auto" class="spinny favicon"></a><br>
|
||||
|
||||
<div class="greeting">
|
||||
<img src="https://cdn.discordapp.com/attachments/902195395264905217/1062706739969019984/ball_35.png" width="150" height="150" class="greeting-l">
|
||||
<img src="https://gdicon.oat.zone/icon.png?type=<%=type_str%>&value=<%=icon_value%>&color1=<%=color1%>&color2=<%=color2%><%=glow ? "&glow=1" : ""%>" width="150" height="150" class="greeting-l">
|
||||
<div class="greeting-r">
|
||||
<div class="greeting-top">
|
||||
<div class="greeting-top-left">
|
||||
|
|
|
@ -36,12 +36,34 @@
|
|||
<form action="/accounts/settings" method="post">
|
||||
<label for="username">Username</label><br>
|
||||
<input type="text" id="username" name="username" minlength="3" maxlength="16" required value="<%= username %>" /><br>
|
||||
<label for="email">Email</label><br>
|
||||
<input type="email" id="email" name="email" value="<%= email %>" /><br>
|
||||
<hr>
|
||||
<input type="submit" value="Update Account" />
|
||||
</form>
|
||||
|
||||
<br>
|
||||
|
||||
<!--
|
||||
<form action="/accounts/settings" method="post">
|
||||
Messages<br>
|
||||
<input type="radio" id="messages_disabled" name="messages_status" value="0"><label for="messages_disabled">Disabled</label><br>
|
||||
<input type="radio" id="messages_friends" name="messages_status" value="1"><label for="messages_friends">Friends only</label><br>
|
||||
<input type="radio" id="messages_all" name="messages_status" value="2"><label for="messages_all">Open to all</label><br>
|
||||
Friend Requests<br>
|
||||
<input type="radio" id="fr_disabled" name="fr_status" value="0"><label for="fr_disabled">Disabled</label><br>
|
||||
<input type="radio" id="fr_all" name="fr_status" value="1"><label for="fr_all">Enabled</label><br>
|
||||
Comments <small>(exclusively client-side!)</small><br>
|
||||
<input type="radio" id="comments_disabled" name="comments_status" value="0"><label for="comments_disabled">Disabled</label><br>
|
||||
<input type="radio" id="comments_friends" name="comments_status" value="1"><label for="comments_friends">Friends only</label><br>
|
||||
<input type="radio" id="comments_all" name="comments_status" value="2"><label for="comments_all">Open to all</label><br>
|
||||
<hr>
|
||||
<input type="submit" value="Update Profile" />
|
||||
</form>
|
||||
|
||||
<br>
|
||||
-->
|
||||
|
||||
<form action="/accounts/settings" method="post">
|
||||
<label for="old_password">Old password</label><br>
|
||||
<input type="password" id="old_password" name="old_password" minlength="3" maxlength="16" required/><br>
|
||||
|
|
|
@ -12,7 +12,10 @@ CrystalGauntlet.template_endpoints["/accounts"] = ->(context : HTTP::Server::Con
|
|||
username = nil
|
||||
Templates.auth()
|
||||
|
||||
stars, demons, coins, user_coins, diamonds, creator_points = DATABASE.query_one("select stars, demons, coins, user_coins, diamonds, creator_points from users where id = ?", user_id, as: {Int32, Int32, Int32, Int32, Int32, Int32})
|
||||
stars, demons, coins, user_coins, diamonds, creator_points, icon_type, color1, color2, cube, ship, ball, ufo, wave, robot, spider, glow = DATABASE.query_one("select stars, demons, coins, user_coins, diamonds, creator_points, icon_type, color1, color2, cube, ship, ball, ufo, wave, robot, spider, glow from users where id = ?", user_id, as: {Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32})
|
||||
|
||||
icon_value = [cube, ship, ball, ufo, wave, robot, spider][icon_type]
|
||||
type_str = ["cube", "ship", "ball", "ufo", "wave", "robot", "spider"][icon_type]
|
||||
|
||||
ECR.embed("./public/template/account_management.ecr", context.response)
|
||||
}
|
||||
|
|
|
@ -11,14 +11,16 @@ CrystalGauntlet.template_endpoints["/accounts/settings"] = ->(context : HTTP::Se
|
|||
|
||||
Templates.auth()
|
||||
|
||||
email = DATABASE.query_one("select email from accounts where id = ?", account_id, as: {String})
|
||||
|
||||
result = nil
|
||||
|
||||
params = context.request.body.try { |b| URI::Params.parse(b.gets_to_end) }
|
||||
if params
|
||||
begin
|
||||
if params["username"]?
|
||||
if params["username"]? && params["username"] != username
|
||||
# todo: dedup this and the gd register endpoint
|
||||
username = params["username"].strip
|
||||
username = Clean.clean_basic(params["username"].strip)
|
||||
if username.size < 3
|
||||
raise "Username must at least be 3 characters long"
|
||||
end
|
||||
|
@ -39,6 +41,16 @@ CrystalGauntlet.template_endpoints["/accounts/settings"] = ->(context : HTTP::Se
|
|||
result = "Changed username successfully"
|
||||
end
|
||||
|
||||
if params["email"]?
|
||||
email = params["email"].strip
|
||||
|
||||
if email.size > 254
|
||||
raise "Invalid email (too long)"
|
||||
end
|
||||
|
||||
DATABASE.exec("update accounts set email = ? where id = ?", email, account_id)
|
||||
end
|
||||
|
||||
if params["old_password"]? && params["new_password"]? && params["repeat_new_password"]?
|
||||
if params["repeat_new_password"] != params["new_password"]
|
||||
raise "New password and repeated password do not match"
|
||||
|
|
Loading…
Reference in New Issue