Welcome Guest, Not a member yet? Register   Sign In
Ajax login form token Vs normal login
#1

Hello skunkbad

I need to ask you can we use ajax login and normal login together ?? 
why the form_open function create different name for token  below is my code above is ajax and below is normal submit form
Code:
<form action="http://localhost/atio/auth/ajax_attempt_login" id="login-form" method="post" accept-charset="utf-8">
<input type="hidden" name="loginToken" value="6253226d" />
                            <input type="text" name="login_string" id="login-string" class="form-control" placeholder="Username">
                            <input type="password" name="login_pass" id="login-pass" class="form-control form_input password" placeholder="Password"  autocomplete="off" readonly="readonly" onfocus="this.removeAttribute('readonly');" />
                            <input type="hidden" id="max_allow_attempts" value="5" />
                            <input type="hidden" id="mins_hold" value="10" />
                            <input type="submit" class="btn btn-default" value="Login" id="submit-button">
                            <a href="#" class="btn btn-link">Forgot Password?</a>
                        </form>
<form action="http://localhost/atio/login?redirect=" class="std-form" method="post" accept-charset="utf-8">
<input type="hidden" name="loginToken" value="6253226d" />
  <div>
    <h2>Login</h2>
    <section>
        <div class="row">
            <div class="col-sm-12">
            <input type="text" class="form-control" name="login_string" id="login_string" placeholder="Username" autocomplete="off" maxlength="255" required />
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <input type="password" name="login_pass" id="login_pass" class="form-control" placeholder="Password" autocomplete="off" readonly="readonly" onfocus="this.removeAttribute('readonly');" />
            </div>
        </div>
    </section>
    </div>
    <hr class="mt30">
    <input type="submit" class="btn btn-default pull-left" name="submit" value="Login" id="submit_button" />
    <a href="#" class="pull-right">Can't access your account?</a>
</div>
</form>



 You can see both form have same name for token which is loginToken , But when i place the ajax form in different form it give me below output with token name token
Code:
<form action="http://localhost/atio/auth/ajax_attempt_login" id="login-form" method="post" accept-charset="utf-8">
<input type="hidden" name="token" value="5f7abfdd" />
                            <input type="text" name="login_string" id="login-string" class="form-control" placeholder="Username">
                            <input type="password" name="login_pass" id="login-pass" class="form-control form_input password" placeholder="Password"  autocomplete="off" readonly="readonly" onfocus="this.removeAttribute('readonly');" />
                            <input type="hidden" id="max_allow_attempts" value="5" />
                            <input type="hidden" id="mins_hold" value="10" />
                            <input type="submit" class="btn btn-default" value="Login" id="submit-button">
                            <a href="#" class="btn btn-link">Forgot Password?</a>
                        </form>

 
I want to use external js for ajax submission  instead of passing jquery code to view everytime.

Why the From_token is empty..

PHP Code:
string     Pawan6161
 password   
= @#Pawan6161@#
 
form_token 
 
token_jar  = ["2bafb732"
Reply
#2

Take a look at the ajax_login method of the Examples controller. It clearly shows how to do an Ajax login, and shows how to change the token name.
Reply
#3

(This post was last modified: 10-18-2018, 09:44 AM by Pawan6161.)

Its fixed i need to assign token name on every page from which i need ajax login

$this->tokens->name = config_item('login_token_name');
Reply




Theme © iAndrew 2016 - Forum software by © MyBB