Foren

User login information - When a user last logged in

thumbnail
Ryan Terwedo, geändert vor 13 Jahren.

User login information - When a user last logged in

Junior Member Beiträge: 94 Beitrittsdatum: 31.10.08 Neueste Beiträge
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
thumbnail
Amos Fong, geändert vor 13 Jahren.

RE: User login information - When a user last logged in

Liferay Legend Beiträge: 2047 Beitrittsdatum: 07.10.08 Neueste Beiträge
Hey Ryan,

If you have the user object you can use this method:

	public Date getLastLoginDate() {
		return _lastLoginDate;
	}


I don't think a history is kept anywhere though.
thumbnail
Ryan Terwedo, geändert vor 13 Jahren.

RE: User login information - When a user last logged in

Junior Member Beiträge: 94 Beitrittsdatum: 31.10.08 Neueste Beiträge
Thanks... I have no idea where I would use that (Its been forever since I coded). Any help on where this would go?

Thanks!!
thumbnail
Sandeep Nair, geändert vor 13 Jahren.

RE: User login information - When a user last logged in

Liferay Legend Beiträge: 1744 Beitrittsdatum: 06.11.08 Neueste Beiträge
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.
thumbnail
Marcus Souza, geändert vor 13 Jahren.

RE: User login information - When a user last logged in

Junior Member Beiträge: 58 Beitrittsdatum: 31.03.09 Neueste Beiträge
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
thumbnail
Sandeep Nair, geändert vor 13 Jahren.

RE: User login information - When a user last logged in

Liferay Legend Beiträge: 1744 Beitrittsdatum: 06.11.08 Neueste Beiträge
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
thumbnail
Marcus Souza, geändert vor 13 Jahren.

RE: User login information - When a user last logged in

Junior Member Beiträge: 58 Beitrittsdatum: 31.03.09 Neueste Beiträge
It works. Thanks a lot Sandeep. Where are the library with all methodes? then I dont need to ask next time.
Marcus
thumbnail
Sandeep Nair, geändert vor 13 Jahren.

RE: User login information - When a user last logged in

Liferay Legend Beiträge: 1744 Beitrittsdatum: 06.11.08 Neueste Beiträge
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, geändert vor 12 Jahren.

RE: User login information - When a user last logged in

New Member Beiträge: 9 Beitrittsdatum: 02.11.11 Neueste Beiträge
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:

$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
thumbnail
David H Nebinger, geändert vor 12 Jahren.

RE: User login information - When a user last logged in

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
'mm' is minute, 'MM' is month.
Ken Patrick, geändert vor 12 Jahren.

RE: User login information - When a user last logged in

New Member Beiträge: 9 Beitrittsdatum: 02.11.11 Neueste Beiträge
thank you!
thumbnail
chethan bd, geändert vor 11 Jahren.

RE: User login information - When a user last logged in

Junior Member Beiträge: 29 Beitrittsdatum: 27.03.12 Neueste Beiträge
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:
$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, geändert vor 11 Jahren.

RE: User login information - When a user last logged in

New Member Beiträge: 13 Beitrittsdatum: 21.08.12 Neueste Beiträge
Anyone know if it possible to see this through the control panel GUI?