Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyCrazy committed Sep 4, 2018
1 parent 2f8bf68 commit a302694
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
4 changes: 0 additions & 4 deletions SpotifyAPI.Web.Auth/AuthorizationCodeAuth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,7 @@ public Task<bool> GetEmpty(WebServer server, HttpListenerContext context)
Error = error
}));

#if NETSTANDARD2_0
return context.StringResponseAsync("OK - This window can be closed now");
#else
return context.StringResponseAsync("OK - This window can be closed now");
#endif
}

[WebApiHandler(HttpVerbs.Post, "/")]
Expand Down
20 changes: 13 additions & 7 deletions SpotifyAPI.Web.Auth/ImplictGrantAuth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
using Unosquare.Labs.EmbedIO;
using Unosquare.Labs.EmbedIO.Constants;
using Unosquare.Labs.EmbedIO.Modules;
#if NETSTANDARD2_0
using System.Net.Http;
#endif
#if NET46
using System.Net.Http;
using HttpListenerContext = Unosquare.Net.HttpListenerContext;
#endif

namespace SpotifyAPI.Web.Auth
{
Expand All @@ -27,14 +34,14 @@ protected override WebServer AdaptWebServer(WebServer webServer)

public class ImplictGrantAuthController : WebApiController
{
[WebApiHandler(HttpVerbs.Get, "/authe")]
public bool GetAuth(WebServer server, HttpListenerContext context)
[WebApiHandler(HttpVerbs.Get, "/auth")]
public Task<bool> GetAuth(WebServer server, HttpListenerContext context)
{
string state = context.Request.QueryString["state"];
SpotifyAuthServer<Token> auth = ImplictGrantAuth.GetByState(state);
if (auth == null)
return true; /*context.StringResponseAsync(
$"Failed - Unable to find auth request with state \"{state}\" - Please retry");*/
return context.StringResponseAsync(
$"Failed - Unable to find auth request with state \"{state}\" - Please retry");

Token token;
string error = context.Request.QueryString["error"];
Expand All @@ -58,9 +65,8 @@ public bool GetAuth(WebServer server, HttpListenerContext context)
};
}

Task.Factory.StartNew(() => auth?.TriggerAuth(token));
return true;
// return context.StringResponseAsync("OK - This window can be closed now");
Task.Factory.StartNew(() => auth.TriggerAuth(token));
return context.StringResponseAsync("OK - This window can be closed now");
}
}
}

0 comments on commit a302694

Please sign in to comment.