Add admin panel authentication and login system
Features: - Login page with username/email + password - Registration page for new accounts - Logout functionality - Cookie-based authentication (30-day sessions) - Auto-redirect to login for unauthorized access - User dropdown in navbar with logout link Security: - All admin pages now require authentication - [Authorize] attribute on all admin PageModels - Redirect to /Login if not authenticated - Auto-login after registration UI: - Beautiful gradient login/register pages - Consistent styling with admin panel - User info displayed in navbar - Logout link in dropdown menu Starting resources for new users: - 100,000 Gold - 500,000 Cash - Level 1 - Full admin panel access Ready for production deployment!
This commit is contained in:
208
RR3CommunityServer/Pages/Register.cshtml
Normal file
208
RR3CommunityServer/Pages/Register.cshtml
Normal file
@@ -0,0 +1,208 @@
|
||||
@page
|
||||
@model RR3CommunityServer.Pages.RegisterModel
|
||||
@{
|
||||
ViewData["Title"] = "Register";
|
||||
Layout = null;
|
||||
}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Register - RR3 Community Server</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.register-container {
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 10px 40px rgba(0,0,0,0.2);
|
||||
padding: 40px;
|
||||
width: 100%;
|
||||
max-width: 450px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
text-align: center;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.logo h1 {
|
||||
color: #667eea;
|
||||
font-size: 28px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.logo p {
|
||||
color: #666;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.form-group input {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
border: 2px solid #e0e0e0;
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
transition: border-color 0.3s;
|
||||
}
|
||||
|
||||
.form-group input:focus {
|
||||
outline: none;
|
||||
border-color: #667eea;
|
||||
}
|
||||
|
||||
.error-message {
|
||||
background: #fee;
|
||||
border: 1px solid #fcc;
|
||||
border-radius: 6px;
|
||||
padding: 12px;
|
||||
color: #c33;
|
||||
margin-bottom: 20px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.success-message {
|
||||
background: #efe;
|
||||
border: 1px solid #cfc;
|
||||
border-radius: 6px;
|
||||
padding: 12px;
|
||||
color: #363;
|
||||
margin-bottom: 20px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.btn-register {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s, box-shadow 0.2s;
|
||||
}
|
||||
|
||||
.btn-register:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
|
||||
}
|
||||
|
||||
.btn-register:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.login-link {
|
||||
text-align: center;
|
||||
margin-top: 20px;
|
||||
color: #666;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.login-link a {
|
||||
color: #667eea;
|
||||
text-decoration: none;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.login-link a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.info-box {
|
||||
background: #e3f2fd;
|
||||
border: 1px solid #90caf9;
|
||||
border-radius: 6px;
|
||||
padding: 12px;
|
||||
margin-bottom: 20px;
|
||||
font-size: 13px;
|
||||
color: #1976d2;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="register-container">
|
||||
<div class="logo">
|
||||
<h1>🏎️ RR3 Community Server</h1>
|
||||
<p>Create Account</p>
|
||||
</div>
|
||||
|
||||
<div class="info-box">
|
||||
<strong>Starting Resources:</strong><br>
|
||||
• 100,000 Gold<br>
|
||||
• 500,000 Cash<br>
|
||||
• Access to admin panel
|
||||
</div>
|
||||
|
||||
@if (!string.IsNullOrEmpty(Model.ErrorMessage))
|
||||
{
|
||||
<div class="error-message">
|
||||
@Model.ErrorMessage
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (!string.IsNullOrEmpty(Model.SuccessMessage))
|
||||
{
|
||||
<div class="success-message">
|
||||
@Model.SuccessMessage
|
||||
</div>
|
||||
}
|
||||
|
||||
<form method="post">
|
||||
<div class="form-group">
|
||||
<label for="Username">Username</label>
|
||||
<input type="text" id="Username" name="Username" required autofocus minlength="3" />
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="Email">Email</label>
|
||||
<input type="email" id="Email" name="Email" required />
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="Password">Password</label>
|
||||
<input type="password" id="Password" name="Password" required minlength="6" />
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="ConfirmPassword">Confirm Password</label>
|
||||
<input type="password" id="ConfirmPassword" name="ConfirmPassword" required minlength="6" />
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn-register">Create Account</button>
|
||||
</form>
|
||||
|
||||
<div class="login-link">
|
||||
Already have an account? <a asp-page="/Login">Login here</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user