Fóruns

Início » Liferay Portal » English » 2. Using Liferay » General

Visualização combinada Visão plana Exibição em árvore
Tópicos [ Anterior | Próximo ]
toggle
Ryan Terwedo
User login information - When a user last logged in
17 de Novembro de 2010 17:59
Resposta

Ryan Terwedo

Ranking: Junior Member

Mensagens: 93

Data de entrada: 30 de Outubro de 2008

Mensagens recentes

Is there a way to see when a user last logged in or even better, a trail of all their login s?

I have poked around and unless the words I aanm searching for are wrong, I cannot find anything.

Thanks,

Ryan
Amos Fong
RE: User login information - When a user last logged in
17 de Novembro de 2010 19:08
Resposta

Amos Fong

LIFERAY STAFF

Ranking: Liferay Legend

Mensagens: 1844

Data de entrada: 7 de Outubro de 2008

Mensagens recentes

Hey Ryan,

If you have the user object you can use this method:
1
2    public Date getLastLoginDate() {
3        return _lastLoginDate;
4    }


I don't think a history is kept anywhere though.
Ryan Terwedo
RE: User login information - When a user last logged in
17 de Dezembro de 2010 08:52
Resposta

Ryan Terwedo

Ranking: Junior Member

Mensagens: 93

Data de entrada: 30 de Outubro de 2008

Mensagens recentes

Thanks... I have no idea where I would use that (Its been forever since I coded). Any help on where this would go?

Thanks!!
Sandeep Nair
RE: User login information - When a user last logged in
17 de Dezembro de 2010 09:11
Resposta

Sandeep Nair

Ranking: Liferay Legend

Mensagens: 1693

Data de entrada: 5 de Novembro de 2008

Mensagens recentes

Hi,

As Amos said you can just retrieve only the lastloginDate of the user

If you want to find the login date of the logged in user simply use the following

PortalUtil.getUser(request).getLastLoginDate();

If you want loginDate of all users, u can call UserLocalServiceUtil.getUsers(-1,-1);
to retrieve all users in system and then use the above method in a loop.
Marcus Souza
RE: User login information - When a user last logged in
10 de Janeiro de 2011 08:14
Resposta

Marcus Souza

Ranking: Junior Member

Mensagens: 58

Data de entrada: 31 de Março de 2009

Mensagens recentes

Sandeep Nair:
Hi,

As Amos said you can just retrieve only the lastloginDate of the user

If you want to find the login date of the logged in user simply use the following

PortalUtil.getUser(request).getLastLoginDate();

If you want loginDate of all users, u can call UserLocalServiceUtil.getUsers(-1,-1);
to retrieve all users in system and then use the above method in a loop.


I am trying the same thing in a VM File
with the code

$user.getLastLoginDate() --> Mon Jan 10 16:11:47 GMT 2011

I get it, but i cant format or split it

I tried

$splittedLoginDate = $stringUtil.split($user.getLoginDate(), ' ')
$date.format('medium',$user.getLoginDate())

but i get just the same string. can someone pls point me in the right direction?

Marcus
Sandeep Nair
RE: User login information - When a user last logged in
10 de Janeiro de 2011 09:02
Resposta

Sandeep Nair

Ranking: Liferay Legend

Mensagens: 1693

Data de entrada: 5 de Novembro de 2008

Mensagens recentes

You can use date variable to format. For example if you want to get year from date u could use something as

$date.getDate($user.getLoginDate(),"yyyy", $locale)

The above will give you year in your case 2011
Marcus Souza
RE: User login information - When a user last logged in
11 de Janeiro de 2011 00:20
Resposta

Marcus Souza

Ranking: Junior Member

Mensagens: 58

Data de entrada: 31 de Março de 2009

Mensagens recentes

It works. Thanks a lot Sandeep. Where are the library with all methodes? then I dont need to ask next time.
Marcus
Sandeep Nair
RE: User login information - When a user last logged in
11 de Janeiro de 2011 01:26
Resposta

Sandeep Nair

Ranking: Liferay Legend

Mensagens: 1693

Data de entrada: 5 de Novembro de 2008

Mensagens recentes

Actually i am not aware. Basically what i do is i know all the variables that used in vm files are put using VelocityVariable. So i just dig Velocity Variables and then see the init.vm of unstyled theme to see, to which variable is it assigned to.
Ken Patrick
RE: User login information - When a user last logged in
20 de Abril de 2012 08:33
Resposta

Ken Patrick

Ranking: New Member

Mensagens: 9

Data de entrada: 2 de Novembro de 2011

Mensagens recentes

Sandeep Nair:
Actually i am not aware. Basically what i do is i know all the variables that used in vm files are put using VelocityVariable. So i just dig Velocity Variables and then see the init.vm of unstyled theme to see, to which variable is it assigned to.



I can't figure out how to get the month at all, I have it set as:

1$date.getDate($user.getLoginDate(),"dd", $locale)/$date.getDate($user.getLoginDate(),"mm", $locale)/$date.getDate($user.getLoginDate(),"yyyy", $locale)


however that gets me an odd date:

20/53/2012
David H Nebinger
RE: User login information - When a user last logged in
20 de Abril de 2012 09:24
Resposta

David H Nebinger

Community Moderator

Ranking: Liferay Legend

Mensagens: 8353

Data de entrada: 1 de Setembro de 2006

Mensagens recentes

'mm' is minute, 'MM' is month.
Ken Patrick
RE: User login information - When a user last logged in
20 de Abril de 2012 10:37
Resposta

Ken Patrick

Ranking: New Member

Mensagens: 9

Data de entrada: 2 de Novembro de 2011

Mensagens recentes

thank you!
Chethan Barike
RE: User login information - When a user last logged in
13 de Novembro de 2012 23:17
Resposta

Chethan Barike

Ranking: Junior Member

Mensagens: 28

Data de entrada: 27 de Março de 2012

Mensagens recentes

Hi Ken Patrick,

use in this way -- $date.getDate($user.getLastLoginDate(),"dd-MM-yyyy hh:mm:ss",$locale)

Ken Patrick:

I can't figure out how to get the month at all, I have it set as:
1$date.getDate($user.getLoginDate(),"dd", $locale)/$date.getDate($user.getLoginDate(),"mm", $locale)/$date.getDate($user.getLoginDate(),"yyyy", $locale)

however that gets me an odd date:
20/53/2012


BR,
Chethan
Steve Cochran
RE: User login information - When a user last logged in
16 de Novembro de 2012 14:22
Resposta

Steve Cochran

Ranking: New Member

Mensagens: 13

Data de entrada: 21 de Agosto de 2012

Mensagens recentes

Anyone know if it possible to see this through the control panel GUI?