mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-04-04 22:53:27 -04:00
Improve reset auth system
- Add bcrypt.js in resetAuthAction() - Rename init_loginForm() in init_crypto_form() - Load init_crypto_form() everytime (if no #crypto-form, do nothing)
This commit is contained in:
@@ -423,6 +423,9 @@ class FreshRSS_index_Controller extends Minz_ActionController {
|
||||
|
||||
public function resetAuthAction() {
|
||||
Minz_View::prependTitle(_t('reset_auth') . ' · ');
|
||||
Minz_View::appendScript(Minz_Url::display(
|
||||
'/scripts/bcrypt.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/bcrypt.min.js')
|
||||
));
|
||||
|
||||
$this->view->no_form = false;
|
||||
// Enable changement of auth only if Persona!
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
switch (Minz_Configuration::authType()) {
|
||||
case 'form':
|
||||
?><form id="loginForm" method="post" action="<?php echo _url('index', 'formLogin'); ?>">
|
||||
?><form id="crypto-form" method="post" action="<?php echo _url('index', 'formLogin'); ?>">
|
||||
<div>
|
||||
<label for="username"><?php echo _t('username'); ?></label>
|
||||
<input type="text" id="username" name="username" size="16" required="required" maxlength="16" pattern="[0-9a-zA-Z]{1,16}" autofocus="autofocus" />
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<?php } ?>
|
||||
|
||||
<?php if (!$this->no_form) { ?>
|
||||
<form id="loginForm" method="post" action="<?php echo _url('index', 'resetAuth'); ?>">
|
||||
<form id="crypto-form" method="post" action="<?php echo _url('index', 'resetAuth'); ?>">
|
||||
<p class="alert alert-warn">
|
||||
<span class="alert-head"><?php echo _t('attention'); ?></span>
|
||||
<?php echo _t('auth_will_reset'); ?>
|
||||
|
||||
@@ -977,7 +977,7 @@ function init_load_more(box) {
|
||||
}
|
||||
//</endless_mode>
|
||||
|
||||
//<Web login form>
|
||||
//<crypto form (Web login)>
|
||||
function poormanSalt() { //If crypto.getRandomValues is not available
|
||||
var text = '$2a$04$',
|
||||
base = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.0123456789/abcdefghijklmnopqrstuvwxyz';
|
||||
@@ -987,20 +987,24 @@ function poormanSalt() { //If crypto.getRandomValues is not available
|
||||
return text;
|
||||
}
|
||||
|
||||
function init_loginForm() {
|
||||
var $loginForm = $('#loginForm');
|
||||
if ($loginForm.length === 0) {
|
||||
function init_crypto_form() {
|
||||
var $crypto_form = $('#crypto-form');
|
||||
if ($crypto_form.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(window.dcodeIO)) {
|
||||
if (window.console) {
|
||||
console.log('FreshRSS waiting for bcrypt.js…');
|
||||
}
|
||||
window.setTimeout(init_loginForm, 100);
|
||||
window.setTimeout(init_crypto_form, 100);
|
||||
return;
|
||||
}
|
||||
$loginForm.on('submit', function() {
|
||||
$('#loginButton').attr('disabled', '');
|
||||
|
||||
$crypto_form.on('submit', function() {
|
||||
var $submit_button = $(this).find('button[type="submit"]');
|
||||
$submit_button.attr('disabled', '');
|
||||
|
||||
var success = false;
|
||||
$.ajax({
|
||||
url: './?c=javascript&a=nonce&user=' + $('#username').val(),
|
||||
@@ -1027,11 +1031,12 @@ function init_loginForm() {
|
||||
}).fail(function() {
|
||||
alert('Communication error!');
|
||||
});
|
||||
$('#loginButton').removeAttr('disabled');
|
||||
|
||||
$submit_button.removeAttr('disabled');
|
||||
return success;
|
||||
});
|
||||
}
|
||||
//</Web login form>
|
||||
//</crypto form (Web login)>
|
||||
|
||||
//<persona>
|
||||
function init_persona() {
|
||||
@@ -1233,14 +1238,12 @@ function init_all() {
|
||||
}
|
||||
init_notifications();
|
||||
switch (authType) {
|
||||
case 'form':
|
||||
init_loginForm();
|
||||
break;
|
||||
case 'persona':
|
||||
init_persona();
|
||||
break;
|
||||
}
|
||||
init_confirm_action();
|
||||
init_crypto_form();
|
||||
$stream = $('#stream');
|
||||
if ($stream.length > 0) {
|
||||
init_actualize();
|
||||
|
||||
Reference in New Issue
Block a user