email/pass login with sqlite db
This commit is contained in:
@@ -162,3 +162,11 @@ white blanc
|
||||
White Blanc
|
||||
white vs. black blanc vs. Noir
|
||||
confirmed. confirmé(s).
|
||||
Note that login to this instance is reserved to French federation actors plus several external people at our discretion. Send us La connexion à cette instance est réservée aux acteurs de la FFG et à quelques personnes extérieures, à notre discrétion. Envoyez-nous
|
||||
an email un email
|
||||
to request an access. pour demander un accès.
|
||||
(not yet available) (pas encore disponible)
|
||||
Log in using Se connecter avec
|
||||
(reserved to FFG actors) (réservé aux acteurs FFG)
|
||||
Log in using an email Se connecter avec un email
|
||||
password mot de passe
|
||||
|
@@ -8,6 +8,7 @@
|
||||
<ol>
|
||||
<li>
|
||||
<p><b>Stay in the browser</b>: If you prefer convenience, you can simply use the <span class="logo">pairgoth</span> instance graciously hosted by the French Go Federation.</p>
|
||||
<p>Note that login to this instance is reserved to French federation actors plus several external people at our discretion. Send us <a href="mailto:pairgothjeudego.org">an email</a> to request an access.</p>
|
||||
<blockquote>
|
||||
<a class="nobreak" href="/login">Launch <span class="logo">pairgoth</span></a>
|
||||
</blockquote>
|
||||
|
@@ -114,7 +114,7 @@ HTMLFormElement.prototype.val = function(name, value) {
|
||||
let tag = ctl.tagName;
|
||||
let type = tag === 'INPUT' ? ctl.attr('type') : undefined;
|
||||
if (
|
||||
(tag === 'INPUT' && ['text', 'number', 'hidden'].includes(ctl.attr('type'))) ||
|
||||
(tag === 'INPUT' && ['text', 'number', 'hidden', 'password'].includes(ctl.attr('type'))) ||
|
||||
tag === 'SELECT'
|
||||
) {
|
||||
if (hasValue) {
|
||||
|
@@ -30,30 +30,71 @@
|
||||
#elseif($auth == 'oauth')
|
||||
|
||||
<div id="login" class="section">
|
||||
<div>Log in using</div>
|
||||
<div id="oauth-buttons">
|
||||
<div id="oauth-buttons" class="roundbox">
|
||||
#foreach($provider in $oauthProviders)
|
||||
<div>
|
||||
<button id="login-$provider" class="ui floating basic button">$provider</button>
|
||||
</div>
|
||||
<form>
|
||||
<label>Log in using</label>
|
||||
<button id="login-$provider" type="button" class="ui green floating button">$provider</button>
|
||||
#if($provider == 'ffg')
|
||||
(reserved to FFG actors)
|
||||
#end
|
||||
</form>
|
||||
#end
|
||||
</div>
|
||||
<div class="roundbox">
|
||||
Log in using an email
|
||||
<form id="login-form" class="ui form">
|
||||
<div class="centered inline fields">
|
||||
<div class="field">
|
||||
<input name="email" type="text" placeholder="email"/>
|
||||
</div>
|
||||
<div class="field">
|
||||
<input name="password" type="password" placeholder="password"/>
|
||||
</div>
|
||||
<button id="login-email" type="button" class="ui green floating button">Log in</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
async function digestMessage(message) {
|
||||
const msgUint8 = new TextEncoder().encode(message); // encode as (utf-8) Uint8Array
|
||||
const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8); // hash the message
|
||||
const hashArray = Array.from(new Uint8Array(hashBuffer)); // convert buffer to byte array
|
||||
const hashHex = hashArray.map((b) => b.toString(16).padStart(2, '0')).join(''); // convert bytes to hex string
|
||||
return hashHex;
|
||||
}
|
||||
|
||||
onLoad(()=> {
|
||||
#foreach($provider in $oauthProviders)
|
||||
let buttonId = '#login-$provider';
|
||||
let loginURL= '$application.getAttribute("${provider}Provider").getLoginURL($session.id)';
|
||||
// #[[
|
||||
console.log(`buttonId = ${buttonId}`);
|
||||
console.log(`loginURL = ${loginURL}`);
|
||||
$(buttonId).on('click', e => {
|
||||
document.location.href = loginURL;
|
||||
});
|
||||
// ]]#
|
||||
#end
|
||||
// #[[
|
||||
$('#login-email').on('click', e => {
|
||||
let form = $('#login-form')[0]
|
||||
let password = form.val('password');
|
||||
digestMessage(password).then(enc => {
|
||||
let payload = {
|
||||
'email': form.val('email'),
|
||||
'password': enc
|
||||
}
|
||||
api.postJson('login', payload)
|
||||
.then(resp => {
|
||||
if (resp !== 'error' && resp.status === 'ok') {
|
||||
document.location.href = '/index'
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
// ]]#
|
||||
});
|
||||
</script>
|
||||
|
||||
|
Reference in New Issue
Block a user