Should prompt login every time

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Should prompt login every time

J Prasanna Venkatesan
Hi All,

I have the following situation.

1. Say user login with 'user1'.
2. Instead of logging out, user1 closes the browser tab.
3. Now user2 tries to login using the url http://localhost:8081/nexus/index.html in the same browser as user1.
4. Now user2 will be automatically logged in as user1 which is not correct.

Instead we want the application to display login page to user2. Meaning previous session should be killed once the browser window/tab is closed.

Please advice me.

Thanks
J Prasanna
Reply | Threaded
Open this post in threaded view
|

Re: Should prompt login every time

nabcos
Hi,

you can just use the REST API to do the logout call:

    window.onbeforeunload = function() {
        var lock = {};
        Ext.Ajax.request({
            method: "GET",
            url: Sonatype.config.repos.urls.logout,
            callback : function() {
                lock.notify();
            }
        });
        lock.wait();
    };

You need to use wait/notify because the browser does not wait for asynchronous
calls when processing events, and Ext JS 2.3 does not support synchronous Ajax
calls. You could also fall back to using XmlHttpRequest directly.

Tested in Firefox 15, closing a tab (not the whole window).

Ben

On Mon, Sep 3, 2012 at 9:33 AM, J Prasanna Venkatesan
<[hidden email]> wrote:

> Hi All,
>
> I have the following situation.
>
> 1. Say user login with 'user1'.
> 2. Instead of logging out, user1 closes the browser tab.
> 3. Now user2 tries to login using the url
> http://localhost:8081/nexus/index.html in the same browser as user1.
> 4. Now user2 will be automatically logged in as user1 which is not correct.
>
> Instead we want the application to display login page to user2. Meaning
> previous session should be killed once the browser window/tab is closed.
>
> Please advice me.
>
> Thanks
> J Prasanna
>
>
>
> --
> View this message in context: http://maven.40175.n5.nabble.com/Should-prompt-login-every-time-tp5719567.html
> Sent from the Nexus Maven Repository Manager Dev List mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Should prompt login every time

J Prasanna Venkatesan
Thanks for your response.

I am trying to understand our solution

You can just use the REST API to do the logout call:

    window.onbeforeunload = function() {
        var lock = {};
        Ext.Ajax.request({
            method: "GET",
            url: Sonatype.config.repos.urls.logout,
            callback : function() {
                lock.notify();
            }
        });
        lock.wait();
    };

Is this a AJAX way of calling REST API? Where should we plug this one?

You need to use wait/notify because the browser does not wait for asynchronous
calls when processing events, and

Ext JS 2.3 does not support synchronous Ajax
calls. You could also fall back to using XmlHttpRequest directly.

In our case whether we need to use XmlHttpRequest ?
Reply | Threaded
Open this post in threaded view
|

Re: Should prompt login every time

nabcos
I may have confused you, but didn't you already have a plugin that
creates Nexus UI?
window.onbeforeunload holds a function that is called before a window
is unloaded (=closed).
It is unset in Nexus UI and the default plugins, so you can just set
your own. You can do
that when you initialize your plugin UI.

Logout on closing the browser is not supported by Nexus out of the box.
The code below uses the ExtJS library to do the logout, which is what
the Nexus UI uses.
That code worked for me in Firefox 15.

Ben

On Mon, Sep 3, 2012 at 11:31 AM, J Prasanna Venkatesan
<[hidden email]> wrote:

> Thanks for your response.
>
> *I am trying to understand our solution*
>
> You can just use the REST API to do the logout call:
>
>     window.onbeforeunload = function() {
>         var lock = {};
>         Ext.Ajax.request({
>             method: "GET",
>             url: Sonatype.config.repos.urls.logout,
>             callback : function() {
>                 lock.notify();
>             }
>         });
>         lock.wait();
>     };
>
> *Is this a AJAX way of calling REST API? Where should we plug this one?*
>
> You need to use wait/notify because the browser does not wait for
> asynchronous
> calls when processing events, and
>
> Ext JS 2.3 does not support synchronous Ajax
> calls. You could also fall back to using XmlHttpRequest directly.
>
> *In our case whether we need to use XmlHttpRequest ?*
>
>
>
>
> --
> View this message in context: http://maven.40175.n5.nabble.com/Should-prompt-login-every-time-tp5719567p5719608.html
> Sent from the Nexus Maven Repository Manager Dev List mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Should prompt login every time

J Prasanna Venkatesan
Dear Ben,

I am not using any plugin that creates Nexus UI? Please let me know how to create one?

Since I am new to Nexus UI based plugin, please guide me as how to plug this code into that plugin.

Thanks & Regards,
J Prasanna

On Mon, Sep 3, 2012 at 7:12 PM, Benjamin Hanzelmann <[hidden email]> wrote:
I may have confused you, but didn't you already have a plugin that
creates Nexus UI?
window.onbeforeunload holds a function that is called before a window
is unloaded (=closed).
It is unset in Nexus UI and the default plugins, so you can just set
your own. You can do
that when you initialize your plugin UI.

Logout on closing the browser is not supported by Nexus out of the box.
The code below uses the ExtJS library to do the logout, which is what
the Nexus UI uses.
That code worked for me in Firefox 15.

Ben

On Mon, Sep 3, 2012 at 11:31 AM, J Prasanna Venkatesan
<[hidden email]> wrote:
> Thanks for your response.
>
> *I am trying to understand our solution*
>
> You can just use the REST API to do the logout call:
>
>     window.onbeforeunload = function() {
>         var lock = {};
>         Ext.Ajax.request({
>             method: "GET",
>             url: Sonatype.config.repos.urls.logout,
>             callback : function() {
>                 lock.notify();
>             }
>         });
>         lock.wait();
>     };
>
> *Is this a AJAX way of calling REST API? Where should we plug this one?*
>
> You need to use wait/notify because the browser does not wait for
> asynchronous
> calls when processing events, and
>
> Ext JS 2.3 does not support synchronous Ajax
> calls. You could also fall back to using XmlHttpRequest directly.
>
> *In our case whether we need to use XmlHttpRequest ?*
>
>
>
>
> --
> View this message in context: http://maven.40175.n5.nabble.com/Should-prompt-login-every-time-tp5719567p5719608.html
> Sent from the Nexus Maven Repository Manager Dev List mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Should prompt login every time

J Prasanna Venkatesan
Got this one working using NexusIndexHtmlCustomizer. Is this the right way?

Thanks a lot.

On Tue, Sep 4, 2012 at 12:07 PM, JPrasanna Venkatesan <[hidden email]> wrote:
Dear Ben,

I am not using any plugin that creates Nexus UI? Please let me know how to create one?

Since I am new to Nexus UI based plugin, please guide me as how to plug this code into that plugin.

Thanks & Regards,
J Prasanna


On Mon, Sep 3, 2012 at 7:12 PM, Benjamin Hanzelmann <[hidden email]> wrote:
I may have confused you, but didn't you already have a plugin that
creates Nexus UI?
window.onbeforeunload holds a function that is called before a window
is unloaded (=closed).
It is unset in Nexus UI and the default plugins, so you can just set
your own. You can do
that when you initialize your plugin UI.

Logout on closing the browser is not supported by Nexus out of the box.
The code below uses the ExtJS library to do the logout, which is what
the Nexus UI uses.
That code worked for me in Firefox 15.

Ben

On Mon, Sep 3, 2012 at 11:31 AM, J Prasanna Venkatesan
<[hidden email]> wrote:
> Thanks for your response.
>
> *I am trying to understand our solution*
>
> You can just use the REST API to do the logout call:
>
>     window.onbeforeunload = function() {
>         var lock = {};
>         Ext.Ajax.request({
>             method: "GET",
>             url: Sonatype.config.repos.urls.logout,
>             callback : function() {
>                 lock.notify();
>             }
>         });
>         lock.wait();
>     };
>
> *Is this a AJAX way of calling REST API? Where should we plug this one?*
>
> You need to use wait/notify because the browser does not wait for
> asynchronous
> calls when processing events, and
>
> Ext JS 2.3 does not support synchronous Ajax
> calls. You could also fall back to using XmlHttpRequest directly.
>
> *In our case whether we need to use XmlHttpRequest ?*
>
>
>
>
> --
> View this message in context: http://maven.40175.n5.nabble.com/Should-prompt-login-every-time-tp5719567p5719608.html
> Sent from the Nexus Maven Repository Manager Dev List mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]



Reply | Threaded
Open this post in threaded view
|

Re: Should prompt login every time

Benjamin Hanzelmann
In reply to this post by J Prasanna Venkatesan
> I am not using any plugin that creates Nexus UI? Please let me know how to
> create one?

Then I have confused you with someone else, sorry.
Have a look at [1] (and if you are unfamiliar with how to write Nexus plugins
at [2]). You would want to paste my code snippet into the
'myScript.js' file from the example.

[1] and [2] should get you started with a basic Nexus plugin. [3] and [4]
provide more details but are not targeted for UI extension.

Ben

[1] https://docs.sonatype.com/display/SPRTNXOSS/Loading+UI+Resources+From+a+Nexus+Plugin
[2] http://www.sonatype.com/books/nexus-book/reference/plugdev-sect-archetype.html
[3] http://www.sonatype.com/people/2009/07/writing-plugins-for-nexus-part-2/
[4] http://www.sonatype.com/books/nexus-book/reference/plugdev.html

On Tue, Sep 4, 2012 at 8:37 AM, JPrasanna Venkatesan
<[hidden email]> wrote:

> Dear Ben,
>
> I am not using any plugin that creates Nexus UI? Please let me know how to
> create one?
>
> Since I am new to Nexus UI based plugin, please guide me as how to plug this
> code into that plugin.
>
> Thanks & Regards,
> J Prasanna
>
>
> On Mon, Sep 3, 2012 at 7:12 PM, Benjamin Hanzelmann <[hidden email]>
> wrote:
>>
>> I may have confused you, but didn't you already have a plugin that
>> creates Nexus UI?
>> window.onbeforeunload holds a function that is called before a window
>> is unloaded (=closed).
>> It is unset in Nexus UI and the default plugins, so you can just set
>> your own. You can do
>> that when you initialize your plugin UI.
>>
>> Logout on closing the browser is not supported by Nexus out of the box.
>> The code below uses the ExtJS library to do the logout, which is what
>> the Nexus UI uses.
>> That code worked for me in Firefox 15.
>>
>> Ben
>>
>> On Mon, Sep 3, 2012 at 11:31 AM, J Prasanna Venkatesan
>> <[hidden email]> wrote:
>> > Thanks for your response.
>> >
>> > *I am trying to understand our solution*
>> >
>> > You can just use the REST API to do the logout call:
>> >
>> >     window.onbeforeunload = function() {
>> >         var lock = {};
>> >         Ext.Ajax.request({
>> >             method: "GET",
>> >             url: Sonatype.config.repos.urls.logout,
>> >             callback : function() {
>> >                 lock.notify();
>> >             }
>> >         });
>> >         lock.wait();
>> >     };
>> >
>> > *Is this a AJAX way of calling REST API? Where should we plug this one?*
>> >
>> > You need to use wait/notify because the browser does not wait for
>> > asynchronous
>> > calls when processing events, and
>> >
>> > Ext JS 2.3 does not support synchronous Ajax
>> > calls. You could also fall back to using XmlHttpRequest directly.
>> >
>> > *In our case whether we need to use XmlHttpRequest ?*
>> >
>> >
>> >
>> >
>> > --
>> > View this message in context:
>> > http://maven.40175.n5.nabble.com/Should-prompt-login-every-time-tp5719567p5719608.html
>> > Sent from the Nexus Maven Repository Manager Dev List mailing list
>> > archive at Nabble.com.
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [hidden email]
>> > For additional commands, e-mail: [hidden email]
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]