rejetto forum

2.4 template-making guide

rejetto · 57 · 1783

0 Members and 1 Guest are viewing this topic.

Offline dj

  • Tireless poster
  • ****
    • Posts: 217
  • 👣 🐾
    • View Profile
    • PWAs
@danny
I can't reproduce your problem.

I found "username not found" neither in your template nor in the default template.
So perhaps it can be a problem with the login section.
Try to rename the 'login' section to 'signin' and also the links.
Try to test 'unauth' without redirect.


Offline danny

  • Tireless poster
  • ****
    • Posts: 166
    • View Profile
@danny
I can't reproduce your problem.

I found "username not found" neither in your template nor in the default template.
So perhaps it can be a problem with the login section.
Try to rename the 'login' section to 'signin' and also the links.
Try to test 'unauth' without redirect.
Thanks!!!
And, yes, there is an intermittent/rare problem with that.  The 'good problem' is that it mostly works.  The function is more likely to fail with an older android phone (although an updated pc can do that sometimes/rarely).  The problem is least likely to happen if you have menu/users/specify directory redirect after login (still possible--less frequently).  So, there is a testing hardship with both vfs options variety and browser variety. 
Trouble is:  The result of login is not confined to useable output (some of the output is not clickable) and may appear broken.
Goal is: Confine the outcome to only what is clickable/usable (nothing else).

Seems useful to add a fallback-redirect so the responses/error doesn't linger on-screen?


Offline NaitLee

  • Occasional poster
  • *
    • Posts: 82
  • Computer brained boy
    • View Profile
How can I change the login section to avoid the "white screen" (bare server response) problem? 

dj's code instantly sent ("submit") changepwd data to server side, parsed by the macro from takeback.

In your code the form instantly submitted password to server, and instantly got the changepwd result, which is simply a plain string "OK (1)".
Seems page XHR response and page refresh happens at same time, that's may why your problem appears with a chance.
Additionally, dj's code should get a responce "ok" (not "OK (1)"), then recognizes changepwd success, otherwise fails with only "user or password don't match".

In takeback I did not use a form, (this is not standard, I'm going to correct it with a form and override its submit() function, just like HFS default tpl)
 by clicking "Okay" the password data is sent to server via XHR, returning that "OK (1)", and dealt by an alert().

You can have a look of my code, then adapt it to password form's submit():

Code: [Select]
function changePwd(newpass) {
        var xhr = new XMLHttpRequest();
        xhr.open('POST', '?mode=section&id=ajax.changepwd');
        xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        xhr.onreadystatechange = function() {
        if (xhr.readyState === 4 && xhr.status === 200) {
            console.log(xhr.responseText);
            var code = ( xhr.responseText.split('(')[1] == undefined ? -1 : xhr.responseText.split('(')[1].split(')')[0] );
            if (code == "1") {
                alert('{.!Complete! Use your new password next time!.}');
                beforeRedirect();
            } else {
                if (code == "0") {
                    alert("{.!You cannot change your password!.}");
                } else if (code == "3") {
                    alert("{.!Failed: Old password you input is wrong!.}");
                } else if (code == "4") {
                    alert("{.!Macro is detected in your input. Please do not attack..}");
                } else if (xhr.responseText.trim() == "bad session") {
                    alert("{.!Bad session. Try to refresh the page..}");
                } else {
                    alert('{.!Unknown error.}: \n'+xhr.responseText.trim());
                }
            }
            }
        };
        xhr.send("token={.cookie|HFS_SID_.}" + "&old=" + sha256(oldpwd.value) + "&new="+btoa(unescape(encodeURIComponent(newpass))));
    }

Or adapt dj's changepwd ajax.
Takeback's changepwd ajax is updated too, have a look as well.
« Last Edit: June 22, 2020, 11:02:42 AM by NaitLee »
Thanks for noticing me :D , I'm just someone normal like others here :D
But don't forget to check out my template ;P


Offline danny

  • Tireless poster
  • ****
    • Posts: 166
    • View Profile
Should the usage of HFS now be confined to either those degreed in javascript or only-default?  I need to know.  For all other cases then [login] section should not have been redacted from HFS2.4.  This is a very good time to decide what happens when the users try to log-in. 
The varieties need to be restricted to what is useful (and clickable--phone/mobile needs clickable).  Anyway there is need of a restricted set of fixed parameters.

P.S.  It usually does work well.  But, we need to control/define/specify what happens when it doesn't. It is a goal.


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13275
    • View Profile
I found "username not found" neither in your template nor in the default template.
So perhaps it can be a problem with the login section.

"username not found" is  in the EXE, one of the errors the login can return.

Should the usage of HFS now be confined to either those degreed in javascript or only-default?  I need to know. 

at the moment javascript is needed, yes.
This doesn't mean you need to master it, you can just copy and adapt from the default tpl.
For example, adding these lines to your tpl will let you execute showLogin() which in turn will show the dialog.
Like for example  <input type=button onclick="showlogin()" value="Login please" />

Code: [Select]
<script>
var HFS = { user: '{.js encode|%user%.}', sid: '{.cookie|HFS_SID_.}', }
</script>
<link rel="stylesheet" href="/~style.css" type="text/css">
<script type="text/javascript" src="/?mode=jquery"></script>
<script type="text/javascript" src="/~lib.js"></script>

This is not the only way, i just wrote it now.
Probably there is space for improv to let other tpl take just as little as needed for the login.
I know this stuff is much more complicated, guys, but the result is much better, the experience is more what people expect. This is how every bloody website has been loggin you in in the last 10 years. We were stuck in the past.
Maybe with more time I'll be able to give you an alternative that won't force you into javascript, but I fear final 2.4.0 will be like this.


Offline danny

  • Tireless poster
  • ****
    • Posts: 166
    • View Profile
...Probably there is space for improv to let other tpl take just as little as needed for the login...
That could be good.  Currently, login is working nicely with no external calls (no jquery, no css, no extras).  So, maybe a simplified/minimized example could be made? 


Offline dj

  • Tireless poster
  • ****
    • Posts: 217
  • 👣 🐾
    • View Profile
    • PWAs
Maybe with more time I'll be able to give you an alternative

additional manual add [api level] to template
tested with Throwback


Offline danny

  • Tireless poster
  • ****
    • Posts: 166
    • View Profile
Instead of <a href="/~login>log-in/out</a> with [login|public],
Is it possible to link to [login] (private)? 


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13275
    • View Profile
(Going to make multi-file select to Takeback. Almost done.)
A question: in a folder, after getting (only) selected filenames, how to archive them without jQuery?

something like this
[...document.getElementsByClassName('selector')].filter(x=> x.checked).map(x=> x.parentNode.getAttribute('href'))


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13275
    • View Profile
Instead of <a href="/~login>log-in/out</a> with [login|public],
Is it possible to link to [login] (private)? 

nope, that's the whole sense of public/private, nothing else


Offline danny

  • Tireless poster
  • ****
    • Posts: 166
    • View Profile