diff --git a/Watcher/Controllers/AuthController.cs b/Watcher/Controllers/AuthController.cs index 4869c7e..bd15c18 100644 --- a/Watcher/Controllers/AuthController.cs +++ b/Watcher/Controllers/AuthController.cs @@ -1,8 +1,10 @@ using System.Security.Claims; +using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; using Watcher.Data; using Watcher.ViewModels; @@ -124,7 +126,7 @@ public class AuthController : Controller if (!string.IsNullOrWhiteSpace(model.NewPassword)) { - user.PreferredUsername = BCrypt.Net.BCrypt.HashPassword(model.NewPassword); + user.Password = BCrypt.Net.BCrypt.HashPassword(model.NewPassword); } _context.SaveChanges(); @@ -140,14 +142,19 @@ public class AuthController : Controller public IActionResult UserSettings() { var username = User.Identity?.Name; + var claims = User.Claims.Select(c => new { c.Type, c.Value }).ToList(); + var user = _context.Users.FirstOrDefault(u => u.PreferredUsername == username); if (user == null) return NotFound(); - var model = new EditUserSettingsViewModel - { - Username = user.PreferredUsername - }; - return View(model); + var DbProvider = _context.Database.ProviderName; + + ViewBag.Name = username; + ViewBag.Claims = claims; + ViewBag.IdentityProvider = user.IdentityProvider; + ViewBag.DbProvider = DbProvider; + + return View(); } // Edit speichern @@ -162,6 +169,8 @@ public class AuthController : Controller var user = _context.Users.FirstOrDefault(u => u.PreferredUsername == username); if (user == null) return NotFound(); + var databaseProvider = _context.Database.ProviderName; + user.PreferredUsername = model.Username; // Passwort ändern diff --git a/Watcher/Views/Auth/Info.cshtml b/Watcher/Views/Auth/Info.cshtml index 81536ea..4e73972 100644 --- a/Watcher/Views/Auth/Info.cshtml +++ b/Watcher/Views/Auth/Info.cshtml @@ -91,34 +91,4 @@ - - @if (isAdmin) - { -
@(ViewBag.IdentityProvider ?? "nicht gefunden")
+ +