Spaces:
Runtime error
Runtime error
almakhmri253-stack
security hardening: rate limiting, account lockout, security headers, password strength
8a2f194 Download Controllers/AuthController.cs from azizproject/majlis: direct link, hf CLI and curl.
- Browser
- Download file 1.95 kB
-
https://huggingface.co/spaces/azizproject/majlis/resolve/main/Controllers/AuthController.cs
- Command line
-
hf download hf://spaces/azizproject/majlis/Controllers/AuthController.cs
-
curl -L -o AuthController.cs https://huggingface.co/spaces/azizproject/majlis/resolve/main/Controllers/AuthController.cs
1.95 kB
| using System.Security.Claims; | |
| using Microsoft.AspNetCore.Authorization; | |
| using Microsoft.AspNetCore.Mvc; | |
| using Microsoft.AspNetCore.RateLimiting; | |
| using MajlisManagement.DTOs; | |
| using MajlisManagement.Services.Interfaces; | |
| namespace MajlisManagement.Controllers; | |
| [] | |
| [] | |
| public class AuthController : ControllerBase | |
| { | |
| private readonly IAuthService _auth; | |
| public AuthController(IAuthService auth) => _auth = auth; | |
| /// <summary>تسجيل مستخدم جديد</summary> | |
| [] | |
| [] | |
| public async Task<IActionResult> Register([FromBody] RegisterDto dto) | |
| { | |
| var result = await _auth.RegisterAsync(dto); | |
| return Ok(result); | |
| } | |
| /// <summary>تسجيل الدخول</summary> | |
| [] | |
| [] | |
| public async Task<IActionResult> Login([FromBody] LoginDto dto) | |
| { | |
| var ip = HttpContext.Connection.RemoteIpAddress?.ToString(); | |
| var result = await _auth.LoginAsync(dto, ip); | |
| return Ok(result); | |
| } | |
| /// <summary>تغيير كلمة المرور</summary> | |
| [] | |
| [] | |
| public async Task<IActionResult> ChangePassword([FromBody] ChangePasswordDto dto) | |
| { | |
| var userId = int.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)!); | |
| await _auth.ChangePasswordAsync(userId, dto); | |
| return Ok(new { message = "تم تغيير كلمة المرور بنجاح" }); | |
| } | |
| /// <summary>بيانات المستخدم الحالي</summary> | |
| [] | |
| [] | |
| public IActionResult Me() | |
| { | |
| return Ok(new | |
| { | |
| Id = User.FindFirstValue(ClaimTypes.NameIdentifier), | |
| Name = User.FindFirstValue(ClaimTypes.Name), | |
| Email = User.FindFirstValue(ClaimTypes.Email), | |
| Role = User.FindFirstValue(ClaimTypes.Role) | |
| }); | |
| } | |
| } | |