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

Change default account type to Invidious accounts #42

Merged
merged 1 commit into from Jul 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/invidious.cr
Expand Up @@ -1027,7 +1027,7 @@ get "/login" do |env|
referer ||= "/feed/subscriptions"

account_type = env.params.query["type"]?
account_type ||= "google"
account_type ||= "invidious"

if account_type == "invidious"
captcha = generate_captcha(HMAC_KEY)
Expand Down Expand Up @@ -1144,7 +1144,7 @@ post "/login" do |env|
end

if !tfa_code
next env.redirect "/login?tfa=true"
next env.redirect "/login?tfa=true&type=google"
end

tl = challenge_results[1][2]
Expand Down
40 changes: 20 additions & 20 deletions src/invidious/views/login.ecr
Expand Up @@ -8,31 +8,14 @@
<div class="h-box">
<div class="pure-g">
<div class="pure-u-1-2">
<a class="pure-button <% if account_type == "google" %>pure-button-disabled<% end %>" href="/login">Login to Google</a>
<a class="pure-button <% if account_type == "invidious" %>pure-button-disabled<% end %>" href="/login">Login/Register</a>
</div>
<div class="pure-u-1-2">
<a class="pure-button <% if account_type == "invidious" %>pure-button-disabled<% end %>" href="/login?type=invidious">Login/Register</a>
<a class="pure-button <% if account_type == "google" %>pure-button-disabled<% end %>" href="/login?type=google">Login to Google</a>
</div>
</div>
<hr>
<% if account_type == "google" %>
<form class="pure-form pure-form-stacked" action="/login?referer=<%= referer %>" method="post">
<fieldset>
<label for="email">Email:</label>
<input required class="pure-input-1" name="email" type="email" placeholder="Email">

<label for="password">Password:</label>
<input required class="pure-input-1" name="password" type="password" placeholder="Password">

<% if tfa %>
<label for="tfa">Google verification code:</label>
<input required class="pure-input-1" name="tfa" type="text" placeholder="Google verification code">
<% end %>

<button type="submit" class="pure-button pure-button-primary">Sign in</button>
</fieldset>
</form>
<% elsif account_type == "invidious" %>
<% if account_type == "invidious" %>
<form class="pure-form pure-form-stacked" action="/login?referer=<%= referer %>&type=invidious" method="post">
<fieldset>
<label for="email">User ID:</label>
Expand All @@ -50,6 +33,23 @@
<button type="submit" name="action" value="register" class="pure-button pure-button-primary">Register</button>
</fieldset>
</form>
<% elsif account_type == "google" %>
<form class="pure-form pure-form-stacked" action="/login?referer=<%= referer %>" method="post">
<fieldset>
<label for="email">Email:</label>
<input required class="pure-input-1" name="email" type="email" placeholder="Email">

<label for="password">Password:</label>
<input required class="pure-input-1" name="password" type="password" placeholder="Password">

<% if tfa %>
<label for="tfa">Google verification code:</label>
<input required class="pure-input-1" name="tfa" type="text" placeholder="Google verification code">
<% end %>

<button type="submit" class="pure-button pure-button-primary">Sign in</button>
</fieldset>
</form>
<% end %>
</div>
</div>
Expand Down