aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2022-08-14 20:01:18 -0400
committerB. Stack <bgstack15@gmail.com>2022-08-14 20:01:18 -0400
commit2aecf573c228cd006c3c25af6b43f24961413f72 (patch)
tree182691fb00c979bfd064b4232f1d4126c0cdc405
parentfix js for newmoon (diff)
downloadradicaleinfcloud-2aecf573c228cd006c3c25af6b43f24961413f72.tar.gz
radicaleinfcloud-2aecf573c228cd006c3c25af6b43f24961413f72.tar.bz2
radicaleinfcloud-2aecf573c228cd006c3c25af6b43f24961413f72.zip
add auto-login with localStorage
The app now supports auto-logging in on page load, if localStorage is populated with user, pass, and locale values. However, the app does not set these values at all, so the user must set them in the browser Developer Tools.
-rw-r--r--radicale_infcloud/web/index.html2
-rw-r--r--radicale_infcloud/web/main.js15
2 files changed, 16 insertions, 1 deletions
diff --git a/radicale_infcloud/web/index.html b/radicale_infcloud/web/index.html
index a8b95e4..7f36475 100644
--- a/radicale_infcloud/web/index.html
+++ b/radicale_infcloud/web/index.html
@@ -83,7 +83,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<td data-size="login_input"><input data-type="system_username" type="text" name="username" class="fs" placeholder="Login" /></td>
</tr>
<tr>
- <td data-size="login_input"><input data-type="system_password" type="password" name="password" class="fs" placeholder="Password" /></td>
+ <td data-size="login_input"><input data-type="system_password" type="password" name="password" class="fs" placeholder="Password" title="Use browser localStorage items user, pass, locale for automatic login!"/></td>
</tr>
<tr>
<td data-size="login">
diff --git a/radicale_infcloud/web/main.js b/radicale_infcloud/web/main.js
index 6a8acda..5ef2763 100644
--- a/radicale_infcloud/web/main.js
+++ b/radicale_infcloud/web/main.js
@@ -588,6 +588,17 @@ function getLoggedUser()
function login()
{
$('#LoginLoader').fadeTo(1200, 1, function(){
+ /* Load localStorage values for automatic login
+ * No mechanism is currently provided for saving these values. The user must use Developer Tools
+ to run localStorage.setItem("pass","value") and so on.
+ */
+ if(localStorage.getItem("pass")!=null && localStorage.getItem("user")!=null){
+ $('#LoginPage').find('[data-type="system_username"]').val(localStorage.getItem("user"));
+ $('#LoginPage').find('[data-type="system_password"]').val(localStorage.getItem("pass"));
+ if(localStorage.getItem("locale")!=null){
+ $('#LoginPage').find('[data-type="language"]').val(localStorage.getItem("locale")).change();
+ }
+ }
globalLoginUsername=$('#LoginPage').find('[data-type="system_username"]').val();
globalLoginPassword=$('#LoginPage').find('[data-type="system_password"]').val();
loadConfig();
@@ -1066,6 +1077,10 @@ function globalMain()
mainSettings();
init();
+ /* Automatically log in if using localStorage */
+ if(localStorage.getItem("pass")!=null){
+ $('#LoginPage').find('[data-type="system_login"]').click();
+ }
}
function saveSettings(isFormSave)
bgstack15