Commit c33fa4a4 authored by Malcolm Blaney's avatar Malcolm Blaney

Revert adding "remember me" option to Indieauth module and just

keep users logged in. Updated Usb module to handle the case where
there's a checkbox in the login form anyway.
parent aec36dda
Pipeline #17871539 passed with stage
in 57 seconds
......@@ -91,10 +91,6 @@ class Indieauth extends Base {
'<label for="indieauth-url">Web Address:</label>' .
'<input id="indieauth-url" type="text">' .
'</div>' .
'<div class="form-spacing">' .
'<label for="indieauth-remember">Remember me:</label>' .
'<input id="indieauth-remember" type="checkbox" value="true">' .
'</div>' .
'<button id="indieauth-submit">Log In</button>' .
'<div id="indieauth-info"></div>' .
'</form>';
......
......@@ -3,7 +3,7 @@
// @licstart The following is the entire license notice
// for the JavaScript code in this page.
//
// Copyright (C) 2017 Malcolm Blaney
// Copyright (C) 2018 Malcolm Blaney
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
......@@ -27,5 +27,7 @@
if(!this.dobrado.usb){dobrado.usb={};}
(function(){'use strict';$(function(){if($('.usb').length===0){return;}
$('#usb-create').button().click(create);});function create(){var address=$('#usb-input').val();if(address===''){$('#usb-info').html('');return false;}
var bookmarklet="(function(){document.querySelectorAll"+"('form').forEach(function(form){var input=form.querySelectorAll"+"('input:not([type=button]):not([type=submit]):not([type=hidden])');"+"if(input.length===1&&/login|log.in|sign.in|address/.test"+"(form.innerHTML.toLowerCase())){input[0].value='"+address+"';form.querySelectorAll('input[type=button],input[type=submit],"+"button').forEach(function(button){button.click();});}});}());";var encoded="%28function%28%29%7Bdocument.querySelectorAll"+"%28%27form%27%29.forEach%28function%28form%29%7Bvar%20input%3D"+"form.querySelectorAll%28%27input%3Anot%28%5Btype%3Dbutton%5D%29%3A"+"not%28%5Btype%3Dsubmit%5D%29%3Anot%28%5Btype%3Dhidden%5D%29%27%29%3B"+"if%28input.length%3D%3D%3D1%26%26%2Flogin%7Clog.in%7Csign.in%7C"+"address%2F.test%28form.innerHTML.toLowerCase%28%29%29%29%7Binput"+"%5B0%5D.value%3D%27"+encodeURIComponent(address)+"%27%3Bform.querySelectorAll%28%27input%5Btype%3Dbutton%5D%2Cinput"+"%5Btype%3Dsubmit%5D%2Cbutton%27%29.forEach%28function%28button%29%7B"+"button.click%28%29%3B%7D%29%3B%7D%7D%29%3B%7D%28%29%29%3B";$('#usb-info').html('<p>Save this link to your bookmarks: '+'<a href="javascript:'+bookmarklet+'">Sign In</a>'+'</p><p id="usb-encoded">Note that the javascript in '+'the link above has not been url encoded, as it '+'appears browsers are doing a better job managing '+'this now. If you have any trouble with it you can '+'try this encoded version: <a href="javascript:'+
var bookmarklet="(function(){document.querySelectorAll"+"('form').forEach(function(form){var input=form.querySelectorAll"+"('input:not([type=button]):not([type=submit]):not([type=checkbox])"+":not([type=hidden])');if(input.length===1&&/login|log.in|sign.in|"+"address/.test(form.innerHTML.toLowerCase())){input[0].value='"+
address+"';form.querySelectorAll('input[type=button],input"+"[type=submit],button').forEach(function(button){button.click();});"+"}});}());";var encoded="%28function%28%29%7Bdocument.querySelectorAll"+"%28%27form%27%29.forEach%28function%28form%29%7Bvar%20input%3D"+"form.querySelectorAll%28%27input%3Anot%28%5Btype%3Dbutton%5D%29%3A"+"not%28%5Btype%3Dsubmit%5D%29%3Anot%28%5Btype%3Dcheckbox%5D%29%3Anot"+"%28%5Btype%3Dhidden%5D%29%27%29%3Bif%28input.length%3D%3D%3D1%26%26%2F"+"login%7Clog.in%7Csign.in%7Caddress%2F.test%28form.innerHTML."+"toLowerCase%28%29%29%29%7Binput%5B0%5D.value%3D%27"+
encodeURIComponent(address)+"%27%3Bform.querySelectorAll%28%27input"+"%5Btype%3Dbutton%5D%2Cinput%5Btype%3Dsubmit%5D%2Cbutton%27%29.forEach"+"%28function%28button%29%7Bbutton.click"+"%28%29%3B%7D%29%3B%7D%7D%29%3B%7D%28%29%29%3B";$('#usb-info').html('<p>Save this link to your bookmarks: '+'<a href="javascript:'+bookmarklet+'">Sign In</a>'+'</p><p id="usb-encoded">Note that the javascript in '+'the link above has not been url encoded, as it '+'appears browsers are doing a better job managing '+'this now. If you have any trouble with it you can '+'try this encoded version: <a href="javascript:'+
encoded+'">Sign In</a></p>');return false;}}());
\ No newline at end of file
......@@ -2,7 +2,7 @@
// @licstart The following is the entire license notice
// for the JavaScript code in this page.
//
// Copyright (C) 2017 Malcolm Blaney
// Copyright (C) 2018 Malcolm Blaney
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
......@@ -48,22 +48,24 @@ if (!this.dobrado.usb) {
var bookmarklet = "(function(){document.querySelectorAll" +
"('form').forEach(function(form){var input=form.querySelectorAll" +
"('input:not([type=button]):not([type=submit]):not([type=hidden])');" +
"if(input.length===1&&/login|log.in|sign.in|address/.test" +
"(form.innerHTML.toLowerCase())){input[0].value='" + address +
"';form.querySelectorAll('input[type=button],input[type=submit]," +
"button').forEach(function(button){button.click();});}});}());";
"('input:not([type=button]):not([type=submit]):not([type=checkbox])" +
":not([type=hidden])');if(input.length===1&&/login|log.in|sign.in|" +
"address/.test(form.innerHTML.toLowerCase())){input[0].value='" +
address + "';form.querySelectorAll('input[type=button],input" +
"[type=submit],button').forEach(function(button){button.click();});" +
"}});}());";
var encoded = "%28function%28%29%7Bdocument.querySelectorAll" +
"%28%27form%27%29.forEach%28function%28form%29%7Bvar%20input%3D" +
"form.querySelectorAll%28%27input%3Anot%28%5Btype%3Dbutton%5D%29%3A" +
"not%28%5Btype%3Dsubmit%5D%29%3Anot%28%5Btype%3Dhidden%5D%29%27%29%3B" +
"if%28input.length%3D%3D%3D1%26%26%2Flogin%7Clog.in%7Csign.in%7C" +
"address%2F.test%28form.innerHTML.toLowerCase%28%29%29%29%7Binput" +
"%5B0%5D.value%3D%27" + encodeURIComponent(address) +
"%27%3Bform.querySelectorAll%28%27input%5Btype%3Dbutton%5D%2Cinput" +
"%5Btype%3Dsubmit%5D%2Cbutton%27%29.forEach%28function%28button%29%7B" +
"button.click%28%29%3B%7D%29%3B%7D%7D%29%3B%7D%28%29%29%3B";
"not%28%5Btype%3Dsubmit%5D%29%3Anot%28%5Btype%3Dcheckbox%5D%29%3Anot" +
"%28%5Btype%3Dhidden%5D%29%27%29%3Bif%28input.length%3D%3D%3D1%26%26%2F" +
"login%7Clog.in%7Csign.in%7Caddress%2F.test%28form.innerHTML." +
"toLowerCase%28%29%29%29%7Binput%5B0%5D.value%3D%27" +
encodeURIComponent(address) + "%27%3Bform.querySelectorAll%28%27input" +
"%5Btype%3Dbutton%5D%2Cinput%5Btype%3Dsubmit%5D%2Cbutton%27%29.forEach" +
"%28function%28button%29%7Bbutton.click" +
"%28%29%3B%7D%29%3B%7D%7D%29%3B%7D%28%29%29%3B";
$('#usb-info').html('<p>Save this link to your bookmarks: ' +
'<a href="javascript:' + bookmarklet + '">Sign In</a>' +
......
......@@ -58,9 +58,9 @@ class Login extends Base {
'maxlength="50">' .
'</div>' .
'<div class="form-spacing">' .
'<label for="remember-input">Remember me</label>' .
'<label for="remember-input">Remember me:</label>' .
'<input id="remember-input" type="checkbox" name="remember" ' .
'value="true">'.
'value="true" checked="checked">'.
'</div>' .
'<input class="submit" type="submit" value="submit">' .
'</form>' .
......
......@@ -94,15 +94,10 @@ class User {
else if (isset($_SESSION['user'])) {
$this->name = $_SESSION['user'];
$this->loggedIn = true;
// Indieauth users can also have persistent login.
// Indieauth users are given persistent login by default.
if (isset($_SESSION['indieauth-login'])) {
unset($_SESSION['indieauth-login']);
if (isset($_POST['remember']) && $_POST['remember'] === 'true') {
$this->RememberLogin();
}
else {
$this->ForgetLogin();
}
$this->RememberLogin();
}
}
// Check if a persistent login cookie is being used.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment