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">
<span class="input-group-text" style="width:23ch">Profile URL</span>
</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">
<button class="btn btn-outline-secondary" role="button" id="button-copy-profileurl" onclick="copyToClipboard(document.getElementById('input-profileurl').value);">Copy</button>
</div>

View File

@ -15,7 +15,7 @@
<p>The following users are currently live:</p>
<div class="btn-group btn-group" role="group">
@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>
}

View File

@ -1,4 +1,4 @@
@page "{user}"
@page "/{user}"
@using RTMPDash.DataModels
@model ProfileModel
@{

View File

@ -20,14 +20,21 @@ public class RegisterModel : PageModel {
if (!db.Invites.Any(p => p.Code == Request.Form["code"]))
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) {
//user already exists
Response.Redirect("/Register?e=user_exists");
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
Response.Redirect("/Register?e=user_invalid");
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;

View File

@ -166,7 +166,7 @@ WantedBy=multi-user.target
player.on("ended", function(){
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);
});
});