Skip to content

Commit a108c14

Browse files
author
Mominur Rahman
authored
Merge pull request #12 from app-generator/gh-login
Add GH login
2 parents 7c4bf6c + 18498d8 commit a108c14

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

apps/authentication/routes.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from apps.authentication import blueprint
1616
from apps.authentication.forms import LoginForm, CreateAccountForm
1717
from apps.authentication.models import Users
18+
from apps.config import Config
1819

1920
from apps.authentication.util import verify_pass
2021

@@ -115,6 +116,12 @@ def logout():
115116
return redirect(url_for('home_blueprint.index'))
116117

117118
# Errors
119+
@blueprint.context_processor
120+
def is_github():
121+
if Config.GITHUB_ID and Config.GITHUB_SECRET:
122+
return {'is_github': True}
123+
124+
return {'is_github': False}
118125

119126
@login_manager.unauthorized_handler
120127
def unauthorized_handler():

apps/templates/accounts/login.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ <h3 class="font-weight-bolder text-info text-gradient">Welcome back</h3>
1414
<p class="mb-0">Enter your email and password to sign in</p>
1515
</div>
1616
<div class="card-body">
17+
{% if is_github %}
18+
<div class="text-center">
19+
<a class="btn btn-outline-light" href="{{ url_for('github.login') }}">
20+
<svg aria-hidden="true" class="octicon octicon-mark-github" width="24px" height="32px" version="1.1" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path>
21+
</svg>
22+
</a>
23+
</div>
24+
{% endif %}
1725
<form role="form" method="post">
1826
{{ form.hidden_tag() }}
1927

apps/templates/accounts/register.html

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,14 @@ <h1 class="text-white mb-2 mt-5">Welcome!</h1>
2323
<h5>Register with</h5>
2424
</div>
2525
<div class="row px-xl-5 px-sm-4 px-3">
26-
<div class="col-3 ms-auto px-1">
27-
<a class="btn btn-outline-light w-100" href="javascript:;">
28-
<svg width="24px" height="32px" viewBox="0 0 64 64" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink32">
29-
<g id="Artboard" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
30-
<g id="facebook-3" transform="translate(3.000000, 3.000000)" fill-rule="nonzero">
31-
<circle fill="#3C5A9A" cx="29.5091719" cy="29.4927506" r="29.4882047"></circle>
32-
<path d="M39.0974944,9.05587273 L32.5651312,9.05587273 C28.6886088,9.05587273 24.3768224,10.6862851 24.3768224,16.3054653 C24.395747,18.2634019 24.3768224,20.1385313 24.3768224,22.2488655 L19.8922122,22.2488655 L19.8922122,29.3852113 L24.5156022,29.3852113 L24.5156022,49.9295284 L33.0113092,49.9295284 L33.0113092,29.2496356 L38.6187742,29.2496356 L39.1261316,22.2288395 L32.8649196,22.2288395 C32.8649196,22.2288395 32.8789377,19.1056932 32.8649196,18.1987181 C32.8649196,15.9781412 35.1755132,16.1053059 35.3144932,16.1053059 C36.4140178,16.1053059 38.5518876,16.1085101 39.1006986,16.1053059 L39.1006986,9.05587273 L39.0974944,9.05587273 L39.0974944,9.05587273 Z" id="Path" fill="#FFFFFF"></path>
33-
</g>
34-
</g>
26+
{% if is_github %}
27+
<div class="col-3 mx-auto px-1">
28+
<a class="btn btn-outline-light w-100" href="{{ url_for('github.login') }}">
29+
<svg aria-hidden="true" class="octicon octicon-mark-github" width="24px" height="32px" version="1.1" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path>
3530
</svg>
3631
</a>
3732
</div>
33+
<!--
3834
<div class="col-3 px-1">
3935
<a class="btn btn-outline-light w-100" href="javascript:;">
4036
<svg width="24px" height="32px" viewBox="0 0 64 64" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
@@ -60,11 +56,13 @@ <h5>Register with</h5>
6056
</svg>
6157
</a>
6258
</div>
59+
-->
6360
<div class="mt-2 position-relative text-center">
6461
<p class="text-sm font-weight-bold mb-2 text-secondary text-border d-inline z-index-2 bg-white px-3">
6562
or
6663
</p>
6764
</div>
65+
{% endif %}
6866
</div>
6967
<div class="card-body">
7068
{% if success %}

0 commit comments

Comments
 (0)