From d52fbf96d9b22132cd72af3ef92fe4bb3685d2bf Mon Sep 17 00:00:00 2001 From: DeinFreund Date: Thu, 16 May 2019 00:53:06 +0200 Subject: [PATCH] display information about current linking status in account maintenance --- Zero-K.info/Controllers/HomeController.cs | 6 +++--- Zero-K.info/Views/Shared/UserDetail.cshtml | 9 ++++++++- ZkLobbyServer/DiscordWebApi.cs | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Zero-K.info/Controllers/HomeController.cs b/Zero-K.info/Controllers/HomeController.cs index 2b796e3d1b..113e3ef136 100644 --- a/Zero-K.info/Controllers/HomeController.cs +++ b/Zero-K.info/Controllers/HomeController.cs @@ -249,7 +249,7 @@ public async Task DiscordAuth(string code, string state) { MessageBox.Show("An error occured while linking the Discord account."); } - return View("HomeIndex"); + return Index(); } [AcceptVerbs(HttpVerbs.Post | HttpVerbs.Get)] @@ -336,8 +336,8 @@ private ActionResult ProcessSteamOpenIDResponse(IAuthenticationResponse response case AuthenticationStatus.Failed: return Content("Login failed"); } - return View("HomeIndex"); - } + return RedirectToAction("Index", "Home"); + } public ActionResult Logout(string referer) { diff --git a/Zero-K.info/Views/Shared/UserDetail.cshtml b/Zero-K.info/Views/Shared/UserDetail.cshtml index 0e94417f38..4d0d1e445e 100644 --- a/Zero-K.info/Views/Shared/UserDetail.cshtml +++ b/Zero-K.info/Views/Shared/UserDetail.cshtml @@ -392,8 +392,14 @@

Account maintenance

Link Discord Account

+ @if (Global.Account.DiscordID.HasValue) + { +
+ Your account is currently linked to Discord ID @(Global.Account.DiscordID). +

+ } Login with Discord
-
+

Change password

@if (!string.IsNullOrEmpty(Model.PasswordBcrypt)) { @@ -422,6 +428,7 @@ } @if (Global.IsModerator && Global.AccountID == Model.AccountID) { +

Admin extras

diff --git a/ZkLobbyServer/DiscordWebApi.cs b/ZkLobbyServer/DiscordWebApi.cs index 112df2e645..561d2e3640 100644 --- a/ZkLobbyServer/DiscordWebApi.cs +++ b/ZkLobbyServer/DiscordWebApi.cs @@ -52,7 +52,7 @@ public async Task LinkAccount(string state, string code) if (!userIds.TryGetValue(state, out accountId)) { Trace.TraceWarning("Invalid state " + state); - return; + return false; } var request = new HttpRequestMessage(HttpMethod.Post, "https://discordapp.com/api/oauth2/token");