Skip to content

Instantly share code, notes, and snippets.

@tamizhvendan
Last active December 26, 2016 07:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tamizhvendan/634d28679a3206d69551dc7f751b28d3 to your computer and use it in GitHub Desktop.
Save tamizhvendan/634d28679a3206d69551dc7f751b28d3 to your computer and use it in GitHub Desktop.
Two Factor Authentication in Suave
{% extends "page.liquid" %}
{% block head %}
<title> Enter Verification Code </title>
{% endblock %}
{% block content %}
<div class="container">
<form action="/verify_auth_code" method="POST" role="form">
<div class="form-group">
<label for="Code">Verification Code</label>
<input type="text" name="Code" id="Code" class="form-control" value="">
</div>
<button type="submit" class="btn btn-primary btn-block">Login</button>
</form>
</div>
{% endblock %}
{% extends "page.liquid" %}
{% block head %}
<title> Enable Two Factor Authentication </title>
{% endblock %}
{% block content %}
<div class="container">
<div class="row">
<div class="col-md-offset-2">Scan the QR Code with Google Authenticator and
enter the 6 digit code it generates</div>
</div>
<div class="row">
<div class="col-md-8">
<form action="/enable_two_factor" method="POST" role="form">
<input type="hidden" name="SecretKey" value="{{model.Key}}">
<div class="form-group">
<label for="Code">Verification Code</label>
<input type="text" name="Code" id="Code" class="form-control" value="">
</div>
<button type="submit" class="btn btn-primary btn-block">Enable</button>
</form>
{% if model.Err != "" %}
<p class="alert alert-danger">{{model.Err}}</p>
{% endif %}
</div>
<div class="col-md-4">
<img src="{{model.Url}}"/>
</div>
</div>
</div>
{% endblock %}
{% extends "page.liquid" %}
{% block head %}
<title> Login </title>
{% endblock %}
{% block content %}
<div class="container">
{% if model != "" %}
<p class="alert alert-danger">{{model}}</p>
{% endif %}
<form method="POST" action="/login">
<div class="form-group">
<label for="Username">Username</label>
<input type="text" id="Username" name="Username">
</div>
<div class="form-group">
<label for="Password">Password</label>
<input type="password" id="Password" name="Password">
</div>
<button class="btn btn-primary" type="submit">Login</button>
</form>
</div>
{% endblock %}
<!-- Suave.TwoFactorAuth/views/page.liquid -->
<html>
<head>
{% block head %}
{% endblock %}
<!-- CSS Styles references ... -->
</head>
<body>
<div id="content">
{% block content %}
{% endblock %}
</div>
<div id="scripts">
<!-- JS libaries references ... -->
</div>
</body>
</html>
{% extends "page.liquid" %}
{% block head %}
<title> {{model.Username}}'s Profile </title>
{% endblock %}
{% block content %}
<div class="container">
<h2>Hi {{model.Username}}</h2>
<div>
{% if model.is_two_factor_auth_enabled %}
<a href="/disable_two_factor">Disable Two Factor Authentication</a>
{% else %}
<a href="/enable_two_factor">Enable Two Factor Authentication</a>
{% endif %}
<a href="/logout" class="btn btn-default">logout</a>
</div>
</div>
{% endblock %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment