Update user profile url pattern

This commit is contained in:
Laura Hausmann 2022-12-15 22:18:57 +01:00
parent 1dcbf254b0
commit ba569ac388
Signed by: zotan
GPG Key ID: D044E84C5BE01605
6 changed files with 19 additions and 12 deletions

View File

@ -51,7 +51,7 @@ else {
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text" style="width:23ch">Profile URL</span> <span class="input-group-text" style="width:23ch">Profile URL</span>
</div> </div>
<input type="text" class="form-control" id="input-profileurl" value="@Program.RootDomain/profile/@user.Username" disabled> <input type="text" class="form-control" id="input-profileurl" value="@Program.RootDomain/@user.Username" disabled>
<div class="input-group-append"> <div class="input-group-append">
<button class="btn btn-outline-secondary" role="button" id="button-copy-profileurl" onclick="copyToClipboard(document.getElementById('input-profileurl').value);">Copy</button> <button class="btn btn-outline-secondary" role="button" id="button-copy-profileurl" onclick="copyToClipboard(document.getElementById('input-profileurl').value);">Copy</button>
</div> </div>

View File

@ -15,11 +15,11 @@
<p>The following users are currently live:</p> <p>The following users are currently live:</p>
<div class="btn-group btn-group" role="group"> <div class="btn-group btn-group" role="group">
@foreach (var user in liveUsers) { @foreach (var user in liveUsers) {
<a href="/profile/@user" class="btn btn-primary" role="button">@user</a> <a href="/@user" class="btn btn-primary" role="button">@user</a>
} }
</div> </div>
} }
else { else {
<p>At the moment, no users are live. Please check back later!</p> <p>At the moment, no users are live. Please check back later!</p>
} }
</div> </div>

View File

@ -1,4 +1,4 @@
@page "{user}" @page "/{user}"
@using RTMPDash.DataModels @using RTMPDash.DataModels
@model ProfileModel @model ProfileModel
@{ @{
@ -54,4 +54,4 @@
<p>@user.PronounSubject.FirstCharToUpper() @pronounAdditional not currently live. @user.PronounSubject.FirstCharToUpper() have not specified an announcement URL, so check back later!</p> <p>@user.PronounSubject.FirstCharToUpper() @pronounAdditional not currently live. @user.PronounSubject.FirstCharToUpper() have not specified an announcement URL, so check back later!</p>
} }
} }
</div> </div>

View File

@ -11,28 +11,35 @@ namespace RTMPDash.Pages;
public class RegisterModel : PageModel { public class RegisterModel : PageModel {
public void OnPost() { public void OnPost() {
if (!Request.HasFormContentType if (!Request.HasFormContentType
|| string.IsNullOrWhiteSpace(Request.Form["user"]) || string.IsNullOrWhiteSpace(Request.Form["user"])
|| string.IsNullOrWhiteSpace(Request.Form["pass"]) || string.IsNullOrWhiteSpace(Request.Form["pass"])
|| string.IsNullOrWhiteSpace(Request.Form["code"])) || string.IsNullOrWhiteSpace(Request.Form["code"]))
return; return;
using var db = new AppDb.DbConn(); using var db = new AppDb.DbConn();
if (!db.Invites.Any(p => p.Code == Request.Form["code"])) if (!db.Invites.Any(p => p.Code == Request.Form["code"]))
return; return;
var user = db.Users.FirstOrDefault(p => p.Username == Request.Form["user"].ToString()); var newUser = Request.Form["user"].ToString().ToLowerInvariant();
var user = db.Users.FirstOrDefault(p => p.Username == newUser);
if (user != null) { if (user != null) {
//user already exists //user already exists
Response.Redirect("/Register?e=user_exists"); Response.Redirect("/Register?e=user_exists");
return; return;
} }
if (db.Users.Any(p => p.StreamKey == Request.Form["user"] || p.PrivateAccessKey == Request.Form["user"])) { if (db.Users.Any(p => p.StreamKey == newUser || p.PrivateAccessKey == newUser)) {
//user invalid //user invalid
Response.Redirect("/Register?e=user_invalid"); Response.Redirect("/Register?e=user_invalid");
return; return;
} }
if (newUser is "register" or "login" or "logout" or "privacy" or "stats" or "index" or "error" or "dashboard" or "credits" or "admin" or "content") {
// user invalid
Response.Redirect("/Register?e=user_invalid");
return;
}
user = new User { user = new User {
Username = Request.Form["user"].ToString(), Username = Request.Form["user"].ToString(),
Password = Request.Form["pass"].ToString().Sha256(), Password = Request.Form["pass"].ToString().Sha256(),
@ -49,4 +56,4 @@ public class RegisterModel : PageModel {
HttpContext.Session.SetString("authenticatedUser", user.Username); HttpContext.Session.SetString("authenticatedUser", user.Username);
} }
} }

View File

@ -166,7 +166,7 @@ WantedBy=multi-user.target
player.on("ended", function(){ player.on("ended", function(){
console.log('Stream ended. Redirecting to profile.'); console.log('Stream ended. Redirecting to profile.');
document.location = 'https://chaos.stream/profile/' + window.location.pathname.substring(1); document.location = 'https://chaos.stream/' + window.location.pathname.substring(1);
}); });
}); });