Community discussions

MikroTik App
 
User avatar
neandero
Member Candidate
Member Candidate
Topic Author
Posts: 243
Joined: Fri Jul 17, 2009 11:43 am
Location: Inside Mind

Login.html questions ?

Fri Feb 04, 2011 9:29 am

<body>
$(if chap-id)
<form name= "sendin"  action="$(link-login-only)" method="post"          >
<input type="hidden"  name=  "username"                                 />
<input type="hidden"  name=  "password"                                 />
<input type="hidden"  name=  "dst"                value= "$(link-orig)" />
<input type="hidden"  name=  "popup"              value="true"          />
</form>
<script type="text/javascript" src="/md5.js"></script>
<script type="text/javascript"						 >
function doLogin()
{
document.sendin.username.value = document.login.username.value;
document.sendin.password.value = hexMD5('$(chap-id)' + document.login.password.value + '$(chap-challenge)');
document.sendin.submit();
return false;
}
</script>
$(endif)

<div id="header">
<div id="login"> 

<table border="0">
<form  name= "login"  action="$(link-login-only)" method="post" $(if chap-id) onSubmit= "return doLogin()" $(endif)>
<input type= "hidden" name=  "dst"                value= "$(link-orig)" />
<input type= "hidden" name=  "popup"              value= "true" /> 	
<tr>
<td align="right">USER: </td> <td><input style= "width:80px"; "height:9px"; name="username" type="text"   value="$(username)"/></td>
<td align="right">PASS: </td> <td><input style= "width:80px"; "height:9px"; name="password" type="password"/>                  </td>
<td align="right">&nbsp;</td> <td><input style= "width:40px"; "height:9px";                 type="submit" value="Login" />     </td>
</form>
$(if error)         
<td align="right">Eror: </td> <td><input style= "width:200px"; "height:9px"; name="errcode"  type="text"  value="$(error)"/>    </td>
$(endif)


</tr>
</table>
</div>

..................
..................

when i try to test the page, i see:
$(if chap-id)
and 
$(endif)


$(if error) 
and
$(endif)
showing in my page... would this show up in real page displayed to the user?
it's putting spaces in between lines that it should not put...



also: is there any code that can transform the area of
<div id="login">
to the name of the user once he/she logs in?
I mean the form inputs will be hidden and the user name will be shown instead up until he logs off...?

thanks,
 
SurferTim
Forum Guru
Forum Guru
Posts: 4636
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: Login.html questions ?

Fri Feb 04, 2011 1:21 pm

The text between these if and endif statement will not be displayed if chap-id or the error are blank or not defined.
$(if chap-id)
and
$(endif)

$(if error)
and
$(endif)

If you want to match the number of lines when these variables are blank or not defined, use something like this
$(if error)
$error<br>
$(else)
<br>
$(endif)
The form data will not be displayed on the page, but is available to the user if they use "View Source" in the web browser menu.
 
User avatar
neandero
Member Candidate
Member Candidate
Topic Author
Posts: 243
Joined: Fri Jul 17, 2009 11:43 am
Location: Inside Mind

Re: Login.html questions ?

Sat Feb 05, 2011 2:05 pm

I guess I am looking for something like this:

if(a user logged in)
show (hello username welcome)

else
show (form + input - submit)

is this possible?


many many thanks,
 
SurferTim
Forum Guru
Forum Guru
Posts: 4636
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: Login.html questions ?

Sat Feb 05, 2011 2:18 pm

Mine already does that, kinda. The actual login page will not display again after you are logged in. You need to use the status.html page for the "Welcome" page. The new web browsers do not pop up the status page automatically any more tho. It is a popup window.
 
User avatar
neandero
Member Candidate
Member Candidate
Topic Author
Posts: 243
Joined: Fri Jul 17, 2009 11:43 am
Location: Inside Mind

Re: Login.html questions ?

Sat Feb 05, 2011 2:52 pm

is this a correct method: it must use "chap-id"
$(if login-by != 'mac') <br><div style="text-align: center;">Welcome $(username)!</div><br> $(endif)

$(else)

<form name="sendin" action="$(link-login-only)" method="post">
<input type="hidden" name="username" />
<input type="hidden" name="password" />
</form>

<script type="text/javascript" src="/md5.js"></script>
<script type="text/javascript">
function doLogin() {
document.sendin.username.value = document.login.username.value;
document.sendin.password.value = hexMD5('$(chap-id)' + document.login.password.value + '$(chap-challenge)');
document.sendin.submit(); return false;}
</script>

<form name="login" action="$(link-login-only)" method="post"
onSubmit="return doLogin()"

<table width="100">
<tr>
<td align="right">login      </td><td><input style="width: 80px" name="username" type="text" value="$(username)"/></td> 
<td align="right">password</td><td><input style="width: 80px" name="password" type="password"/></td>
<td>&nbsp;	</td>	<td><input type="submit" value="OK" />											</td>
</tr>
</table>
</form>
$(endif)

 
SurferTim
Forum Guru
Forum Guru
Posts: 4636
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: Login.html questions ?

Sat Feb 05, 2011 2:57 pm

The only time you will see that "Welcome, $(username)" is if the user login failed, probably due to bad user or password. I'm not sure a "Welcome" message would be appropriate at that point.

ADD: I think you would want to use (not that it will work)
$(if logged-in == yes)
Your welcome message that will not be displayed because logged-in should always be no on this page.
$(else)
Your html login page code
$(endif)
 
User avatar
neandero
Member Candidate
Member Candidate
Topic Author
Posts: 243
Joined: Fri Jul 17, 2009 11:43 am
Location: Inside Mind

Re: Login.html questions ?

Sat Feb 05, 2011 3:07 pm

so then anyone to provide a code that would do that:

if (user logged in) welcome user
else (show form) for user to login
?

this whole code is within a small area of the webpage... filled with all other services, links, menus and stuff...

i just need to display the form only once for the user to login... after that the form disappear untill he/she logs off. only then the form will re-appear...
 
SurferTim
Forum Guru
Forum Guru
Posts: 4636
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: Login.html questions ?

Sat Feb 05, 2011 3:16 pm

You should take a look at this thread. It was a very similar request.
http://forum.mikrotik.com/viewtopic.php?f=2&t=48197

Who is online

Users browsing this forum: Amazon [Bot], Kanzler, raiser and 236 guests