Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add twitch login support #153

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ function renderUser() {
<p>
Create a CelesteNet account to show your profile picture in-game and to let the server remember your last channel and command settings.<br>
<br>
<a id="button-auth" class="button" href="/api/discordauth"><span class="button-icon"></span><span>Link your Discord account</span></a><br>
<a id="button-auth" class="button" href="/api/standardauth?state=discord"><span class="button-icon"></span><span>Link your Discord account</span></a><br>
<a id="button-auth" class="button" href="/api/standardauth?state=twitch"><span class="button-icon"></span><span>Link your Twitch account</span></a><br>
<sub style="line-height: 0.5em;">
Linking your account is fully optional and requires telling your browser to store a "cookie." This cookie is only used to keep you logged in.
</sub>
Expand Down
2 changes: 1 addition & 1 deletion CelesteNet.Server.FrontendModule/Frontend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ public NameValueCollection ParseQueryString(string url) {
NameValueCollection nvc = new();

int indexOfSplit = url.IndexOf('?');
if (indexOfSplit == -1)
if (indexOfSplit == -1)
return nvc;
url = url.Substring(indexOfSplit + 1);

Expand Down
11 changes: 9 additions & 2 deletions CelesteNet.Server.FrontendModule/FrontendSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,19 @@ public class FrontendSettings : CelesteNetServerModuleSettings {

// TODO: Separate Discord auth module!
[YamlIgnore]
public string DiscordOAuthURL => $"https://discord.com/oauth2/authorize?client_id={DiscordOAuthClientID}&redirect_uri={Uri.EscapeDataString(DiscordOAuthRedirectURL)}&response_type=code&scope=identify";
public string DiscordOAuthURL => $"https://discord.com/oauth2/authorize?client_id={DiscordOAuthClientID}&redirect_uri={Uri.EscapeDataString(DiscordOAuthRedirectURL)}&response_type=code&scope=identify&state=discord";
[YamlIgnore]
public string DiscordOAuthRedirectURL => $"{CanonicalAPIRoot}/discordauth";
public string DiscordOAuthRedirectURL => $"{CanonicalAPIRoot}/standardauth";
public string DiscordOAuthClientID { get; set; } = "";
public string DiscordOAuthClientSecret { get; set; } = "";

[YamlIgnore]
public string TwitchOAuthURL => $"https://id.twitch.tv/oauth2/authorize?response_type=code&client_id={TwitchOAuthClientID}&redirect_uri={Uri.EscapeDataString(TwitchOAuthRedirectURL)}&response_type=code&state=twitch";
[YamlIgnore]
public string TwitchOAuthRedirectURL => $"{CanonicalAPIRoot}/standardauth";
public string TwitchOAuthClientID { get; set; } = "";
public string TwitchOAuthClientSecret { get; set; } = "";

public HashSet<string> ExecOnlySettings { get; set; } = new();

}
Expand Down
Loading