Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #762 and #763 - Last login time of an user added #772

Merged
merged 5 commits into from
Jun 15, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class UserDataTable extends React.Component {
<DataTable value={users} globalFilter={filterValue} scrollable={true} scrollHeight={maxHeight}>
<Column field="id" header="ID" />
<Column field="username" header="Username" />
<Column field="lastLoginTime" header="Last Login Time" />
<Column field="ldapUser" header="LDAP User" body={(data) => <i className={data.ldapUser ? 'pi pi-check' : 'pi pi-times'}></i>} />
<Column
style={{ width: '3.5rem' }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
import rocks.inspectit.ocelot.user.UserPermissions;
import rocks.inspectit.ocelot.user.UserService;

import java.sql.Timestamp;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Set;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -58,8 +62,12 @@ public class AccountController extends AbstractBaseController {
@ApiResponse(code = 200, message = "The access token", examples =
@Example(value = @ExampleProperty(value = "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiIsImV4cCI6MTU2MTYyODE1NH0.KelDW1OXg9xlMjSiblwZqui7sya4Crq833b-98p8UZ4", mediaType = "text/plain")))
@GetMapping("account/token")
public String acuireNewAccessToken(Authentication user) {
return tokenManager.createToken(user.getName());
public String acuireNewAccessToken(Authentication auth) {
String timeStamp = new SimpleDateFormat("dd/MM/yyyy HH:mm").format(new Date());
User user = userService.getUserByName(auth.getName()).get();
user.setLastLoginTime(timeStamp);
userService.addOrUpdateUser(user);
return tokenManager.createToken(auth.getName());
}

@ApiOperation(value = "Change Password", notes = "Changes the password of the logged in user." +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public class User implements Auditable {
@Column(nullable = false)
private boolean isLdapUser;

@Column
private String lastLoginTime;

@Override
@JsonIgnore
public AuditDetail getAuditDetail() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE user
ADD last_login_time varchar(30);