How to log in when using acegi plugin?

View: New views
5 Messages — Rating Filter:   Alert me  

How to log in when using acegi plugin?

by tomLee :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Here is my login form:
<form action='/myapp/login' method='POST' id='loginForm1' name='loginForm' class='cssform'>
            <div class="login_right">
            <ul>
                <li><input name="j_username" id="j_username" type="text"  class="loginbg"/></li>
                    <li><input name="j_password" type="password" id="j_password" type="text"  class="loginbg"/>

I submit this form by javascript:
 document.loginForm.submit();

In LoginController:
def index = {
        println "bbbbbbbbbbbbbbbb"
                if (isLoggedIn()) {
                        redirect uri: '/user/userInfo'
                }
                else {
                        redirect action: auth, params: params
                }
        }

But I can't see "bbbbbbbbbbbbbbbb" in console. My browser suspend after submitting.

I tried using <form action='myapp/j_spring_security_check'...
but it didn't work properly.

Thanks

Re: How to log in when using acegi plugin?

by antoine_ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Did you use a Javascript debugger to check the value of document.loginForm, and that it is submitted?


Antoine



tomLee a écrit :
Here is my login form: 
<form action='/myapp/login' method='POST' id='loginForm1' name='loginForm'
class='cssform'>
            <div class="login_right">
            	<ul>
                	<li><input name="j_username" id="j_username" type="text" 
class="loginbg"/></li>
                    <li><input name="j_password" type="password"
id="j_password" type="text"  class="loginbg"/>

I submit this form by javascript:
 document.loginForm.submit();

In LoginController:
def index = {
        println "bbbbbbbbbbbbbbbb"
		if (isLoggedIn()) {
			redirect uri: '/user/userInfo'
		}
		else {
			redirect action: auth, params: params
		}
	}

But I can't see "bbbbbbbbbbbbbbbb" in console. My browser suspend after
submitting.

I tried using <form action='myapp/j_spring_security_check'...
but it didn't work properly.

Thanks
  
--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

Re: How to log in when using acegi plugin?

by Burt Beckwith :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This is already a part of the plugin, see auth.gsp. You need to post to j_spring_security_check so the appropriate filter intercepts the submission and does the authentication. Your login controller is just a helper, called after a successful or unsuccessful login.

Note that you need to use "action='/myapp/j_spring_security_check'" with a leading slash to make the URI absolute or do what the plugin code does:

   <form action='${request.contextPath}/j_spring_security_check' method='POST' id='loginForm' class='cssform'>

This is different from what's in auth.gsp since the plugin also supports OpenID and Facebook logins, but the previous line is what would be used with regular logins.

There's a writeup on using Ajax logins here: http://www.grails.org/AcegiSecurity+Plugin+-+Ajax+Authentication

Burt

>
> Here is my login form:
> <form action='/myapp/login' method='POST' id='loginForm1' name='loginForm'
> class='cssform'>
>             <div class="login_right">
>             <ul>
>                 <li><input name="j_username" id="j_username" type="text"
> class="loginbg"/></li>
>                     <li><input name="j_password" type="password"
> id="j_password" type="text"  class="loginbg"/>
>
> I submit this form by javascript:
>  document.loginForm.submit();
>
> In LoginController:
> def index = {
>         println "bbbbbbbbbbbbbbbb"
> if (isLoggedIn()) {
> redirect uri: '/user/userInfo'
> }
> else {
> redirect action: auth, params: params
> }
> }
>
> But I can't see "bbbbbbbbbbbbbbbb" in console. My browser suspend after
> submitting.
>
> I tried using <form action='myapp/j_spring_security_check'...
> but it didn't work properly.
>
> Thanks
>


signature.asc (204 bytes) Download Attachment

Re: How to log in when using acegi plugin?

by tomLee :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have tried j_spring_security_check,but this seems a ajax login,after logged in,the page is stall the same page,not redirect to the page I want, I added redirect in logincontroller, but not working.

Burt Beckwith wrote:
This is already a part of the plugin, see auth.gsp. You need to post to j_spring_security_check so the appropriate filter intercepts the submission and does the authentication. Your login controller is just a helper, called after a successful or unsuccessful login.

Note that you need to use "action='/myapp/j_spring_security_check'" with a leading slash to make the URI absolute or do what the plugin code does:

   <form action='${request.contextPath}/j_spring_security_check' method='POST' id='loginForm' class='cssform'>

This is different from what's in auth.gsp since the plugin also supports OpenID and Facebook logins, but the previous line is what would be used with regular logins.

There's a writeup on using Ajax logins here: http://www.grails.org/AcegiSecurity+Plugin+-+Ajax+Authentication

Burt

>
> Here is my login form:
> <form action='/myapp/login' method='POST' id='loginForm1' name='loginForm'
> class='cssform'>
>             <div class="login_right">
>             <ul>
>                 <li><input name="j_username" id="j_username" type="text"
> class="loginbg"/></li>
>                     <li><input name="j_password" type="password"
> id="j_password" type="text"  class="loginbg"/>
>
> I submit this form by javascript:
>  document.loginForm.submit();
>
> In LoginController:
> def index = {
>         println "bbbbbbbbbbbbbbbb"
> if (isLoggedIn()) {
> redirect uri: '/user/userInfo'
> }
> else {
> redirect action: auth, params: params
> }
> }
>
> But I can't see "bbbbbbbbbbbbbbbb" in console. My browser suspend after
> submitting.
>
> I tried using <form action='myapp/j_spring_security_check'...
> but it didn't work properly.
>
> Thanks
>

 

Re: How to log in when using acegi plugin?

by tomLee :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes, I am sure it submitted.


antoine_ wrote:


 
 


Did you use a Javascript debugger to check the value of
document.loginForm, and that it is submitted?



Antoine



tomLee a écrit :

  Here is my login form:
<form action='/myapp/login' method='POST' id='loginForm1' name='loginForm'
class='cssform'>
            <div class="login_right">
            <ul>
                <li><input name="j_username" id="j_username" type="text"
class="loginbg"/></li>
                    <li><input name="j_password" type="password"
id="j_password" type="text"  class="loginbg"/>

I submit this form by javascript:
 document.loginForm.submit();

In LoginController:
def index = {
        println "bbbbbbbbbbbbbbbb"
                if (isLoggedIn()) {
                        redirect uri: '/user/userInfo'
                }
                else {
                        redirect action: auth, params: params
                }
        }

But I can't see "bbbbbbbbbbbbbbbb" in console. My browser suspend after
submitting.

I tried using <form action='myapp/j_spring_security_check'...
but it didn't work properly.

Thanks
 




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email