mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-394: Determine last active date for users based on history table.
This commit is contained in:
@@ -796,7 +796,7 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date getLastActive() {
|
public Date getLastActive() {
|
||||||
return null;
|
return getModel().getLastActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -114,6 +114,12 @@ public class UserModel extends ObjectModel {
|
|||||||
*/
|
*/
|
||||||
private String organizationalRole;
|
private String organizationalRole;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The date and time that this user was last active, or null if this user
|
||||||
|
* has never logged in.
|
||||||
|
*/
|
||||||
|
private Date lastActive;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new, empty user.
|
* Creates a new, empty user.
|
||||||
*/
|
*/
|
||||||
@@ -465,4 +471,30 @@ public class UserModel extends ObjectModel {
|
|||||||
this.organizationalRole = organizationalRole;
|
this.organizationalRole = organizationalRole;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the date and time that this user was last active, or null if
|
||||||
|
* this user has never logged in.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* The date and time that this user was last active, or null if this
|
||||||
|
* user has never logged in.
|
||||||
|
*/
|
||||||
|
public Date getLastActive() {
|
||||||
|
return lastActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the date and time that this user was last active. This value is
|
||||||
|
* expected to be set automatically via queries, derived from user history
|
||||||
|
* records. It does NOT correspond to an actual column, and values set
|
||||||
|
* manually through invoking this function will not persist.
|
||||||
|
*
|
||||||
|
* @param lastActive
|
||||||
|
* The date and time that this user was last active, or null if this
|
||||||
|
* user has never logged in.
|
||||||
|
*/
|
||||||
|
public void setLastActive(Date lastActive) {
|
||||||
|
this.lastActive = lastActive;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -41,6 +41,7 @@
|
|||||||
<result column="email_address" property="emailAddress" jdbcType="VARCHAR"/>
|
<result column="email_address" property="emailAddress" jdbcType="VARCHAR"/>
|
||||||
<result column="organization" property="organization" jdbcType="VARCHAR"/>
|
<result column="organization" property="organization" jdbcType="VARCHAR"/>
|
||||||
<result column="organizational_role" property="organizationalRole" jdbcType="VARCHAR"/>
|
<result column="organizational_role" property="organizationalRole" jdbcType="VARCHAR"/>
|
||||||
|
<result column="last_active" property="lastActive" jdbcType="TIMESTAMP"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<!-- Select all usernames -->
|
<!-- Select all usernames -->
|
||||||
@@ -63,8 +64,8 @@
|
|||||||
<select id="select" resultMap="UserResultMap">
|
<select id="select" resultMap="UserResultMap">
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
user_id,
|
guacamole_user.user_id,
|
||||||
username,
|
guacamole_user.username,
|
||||||
password_hash,
|
password_hash,
|
||||||
password_salt,
|
password_salt,
|
||||||
password_date,
|
password_date,
|
||||||
@@ -78,13 +79,16 @@
|
|||||||
full_name,
|
full_name,
|
||||||
email_address,
|
email_address,
|
||||||
organization,
|
organization,
|
||||||
organizational_role
|
organizational_role,
|
||||||
|
MAX(start_date) AS last_active
|
||||||
FROM guacamole_user
|
FROM guacamole_user
|
||||||
WHERE username IN
|
LEFT JOIN guacamole_user_history ON guacamole_user_history.user_id = guacamole_user.user_id
|
||||||
|
WHERE guacamole_user.username IN
|
||||||
<foreach collection="identifiers" item="identifier"
|
<foreach collection="identifiers" item="identifier"
|
||||||
open="(" separator="," close=")">
|
open="(" separator="," close=")">
|
||||||
#{identifier,jdbcType=VARCHAR}
|
#{identifier,jdbcType=VARCHAR}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
GROUP BY guacamole_user.user_id
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -93,7 +97,7 @@
|
|||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
guacamole_user.user_id,
|
guacamole_user.user_id,
|
||||||
username,
|
guacamole_user.username,
|
||||||
password_hash,
|
password_hash,
|
||||||
password_salt,
|
password_salt,
|
||||||
password_date,
|
password_date,
|
||||||
@@ -107,16 +111,19 @@
|
|||||||
full_name,
|
full_name,
|
||||||
email_address,
|
email_address,
|
||||||
organization,
|
organization,
|
||||||
organizational_role
|
organizational_role,
|
||||||
|
MAX(start_date) AS last_active
|
||||||
FROM guacamole_user
|
FROM guacamole_user
|
||||||
JOIN guacamole_user_permission ON affected_user_id = guacamole_user.user_id
|
JOIN guacamole_user_permission ON affected_user_id = guacamole_user.user_id
|
||||||
WHERE username IN
|
LEFT JOIN guacamole_user_history ON guacamole_user_history.user_id = guacamole_user.user_id
|
||||||
|
WHERE guacamole_user.username IN
|
||||||
<foreach collection="identifiers" item="identifier"
|
<foreach collection="identifiers" item="identifier"
|
||||||
open="(" separator="," close=")">
|
open="(" separator="," close=")">
|
||||||
#{identifier,jdbcType=VARCHAR}
|
#{identifier,jdbcType=VARCHAR}
|
||||||
</foreach>
|
</foreach>
|
||||||
AND guacamole_user_permission.user_id = #{user.objectID,jdbcType=INTEGER}
|
AND guacamole_user_permission.user_id = #{user.objectID,jdbcType=INTEGER}
|
||||||
AND permission = 'READ'
|
AND permission = 'READ'
|
||||||
|
GROUP BY guacamole_user.user_id
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -124,8 +131,8 @@
|
|||||||
<select id="selectOne" resultMap="UserResultMap">
|
<select id="selectOne" resultMap="UserResultMap">
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
user_id,
|
guacamole_user.user_id,
|
||||||
username,
|
guacamole_user.username,
|
||||||
password_hash,
|
password_hash,
|
||||||
password_salt,
|
password_salt,
|
||||||
password_date,
|
password_date,
|
||||||
@@ -139,10 +146,13 @@
|
|||||||
full_name,
|
full_name,
|
||||||
email_address,
|
email_address,
|
||||||
organization,
|
organization,
|
||||||
organizational_role
|
organizational_role,
|
||||||
|
MAX(start_date) AS last_active
|
||||||
FROM guacamole_user
|
FROM guacamole_user
|
||||||
|
LEFT JOIN guacamole_user_history ON guacamole_user_history.user_id = guacamole_user.user_id
|
||||||
WHERE
|
WHERE
|
||||||
username = #{username,jdbcType=VARCHAR}
|
guacamole_user.username = #{username,jdbcType=VARCHAR}
|
||||||
|
GROUP BY guacamole_user.user_id
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
@@ -41,6 +41,7 @@
|
|||||||
<result column="email_address" property="emailAddress" jdbcType="VARCHAR"/>
|
<result column="email_address" property="emailAddress" jdbcType="VARCHAR"/>
|
||||||
<result column="organization" property="organization" jdbcType="VARCHAR"/>
|
<result column="organization" property="organization" jdbcType="VARCHAR"/>
|
||||||
<result column="organizational_role" property="organizationalRole" jdbcType="VARCHAR"/>
|
<result column="organizational_role" property="organizationalRole" jdbcType="VARCHAR"/>
|
||||||
|
<result column="last_active" property="lastActive" jdbcType="TIMESTAMP"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<!-- Select all usernames -->
|
<!-- Select all usernames -->
|
||||||
@@ -63,8 +64,8 @@
|
|||||||
<select id="select" resultMap="UserResultMap">
|
<select id="select" resultMap="UserResultMap">
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
user_id,
|
guacamole_user.user_id,
|
||||||
username,
|
guacamole_user.username,
|
||||||
password_hash,
|
password_hash,
|
||||||
password_salt,
|
password_salt,
|
||||||
password_date,
|
password_date,
|
||||||
@@ -78,13 +79,16 @@
|
|||||||
full_name,
|
full_name,
|
||||||
email_address,
|
email_address,
|
||||||
organization,
|
organization,
|
||||||
organizational_role
|
organizational_role,
|
||||||
|
MAX(start_date) AS last_active
|
||||||
FROM guacamole_user
|
FROM guacamole_user
|
||||||
WHERE username IN
|
LEFT JOIN guacamole_user_history ON guacamole_user_history.user_id = guacamole_user.user_id
|
||||||
|
WHERE guacamole_user.username IN
|
||||||
<foreach collection="identifiers" item="identifier"
|
<foreach collection="identifiers" item="identifier"
|
||||||
open="(" separator="," close=")">
|
open="(" separator="," close=")">
|
||||||
#{identifier,jdbcType=VARCHAR}
|
#{identifier,jdbcType=VARCHAR}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
GROUP BY guacamole_user.user_id
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -93,7 +97,7 @@
|
|||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
guacamole_user.user_id,
|
guacamole_user.user_id,
|
||||||
username,
|
guacamole_user.username,
|
||||||
password_hash,
|
password_hash,
|
||||||
password_salt,
|
password_salt,
|
||||||
password_date,
|
password_date,
|
||||||
@@ -107,16 +111,19 @@
|
|||||||
full_name,
|
full_name,
|
||||||
email_address,
|
email_address,
|
||||||
organization,
|
organization,
|
||||||
organizational_role
|
organizational_role,
|
||||||
|
MAX(start_date) AS last_active
|
||||||
FROM guacamole_user
|
FROM guacamole_user
|
||||||
JOIN guacamole_user_permission ON affected_user_id = guacamole_user.user_id
|
JOIN guacamole_user_permission ON affected_user_id = guacamole_user.user_id
|
||||||
WHERE username IN
|
LEFT JOIN guacamole_user_history ON guacamole_user_history.user_id = guacamole_user.user_id
|
||||||
|
WHERE guacamole_user.username IN
|
||||||
<foreach collection="identifiers" item="identifier"
|
<foreach collection="identifiers" item="identifier"
|
||||||
open="(" separator="," close=")">
|
open="(" separator="," close=")">
|
||||||
#{identifier,jdbcType=VARCHAR}
|
#{identifier,jdbcType=VARCHAR}
|
||||||
</foreach>
|
</foreach>
|
||||||
AND guacamole_user_permission.user_id = #{user.objectID,jdbcType=INTEGER}
|
AND guacamole_user_permission.user_id = #{user.objectID,jdbcType=INTEGER}
|
||||||
AND permission = 'READ'
|
AND permission = 'READ'
|
||||||
|
GROUP BY guacamole_user.user_id
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -124,8 +131,8 @@
|
|||||||
<select id="selectOne" resultMap="UserResultMap">
|
<select id="selectOne" resultMap="UserResultMap">
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
user_id,
|
guacamole_user.user_id,
|
||||||
username,
|
guacamole_user.username,
|
||||||
password_hash,
|
password_hash,
|
||||||
password_salt,
|
password_salt,
|
||||||
password_date,
|
password_date,
|
||||||
@@ -139,10 +146,13 @@
|
|||||||
full_name,
|
full_name,
|
||||||
email_address,
|
email_address,
|
||||||
organization,
|
organization,
|
||||||
organizational_role
|
organizational_role,
|
||||||
|
MAX(start_date) AS last_active
|
||||||
FROM guacamole_user
|
FROM guacamole_user
|
||||||
|
LEFT JOIN guacamole_user_history ON guacamole_user_history.user_id = guacamole_user.user_id
|
||||||
WHERE
|
WHERE
|
||||||
username = #{username,jdbcType=VARCHAR}
|
guacamole_user.username = #{username,jdbcType=VARCHAR}
|
||||||
|
GROUP BY guacamole_user.user_id
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
@@ -41,6 +41,7 @@
|
|||||||
<result column="email_address" property="emailAddress" jdbcType="VARCHAR"/>
|
<result column="email_address" property="emailAddress" jdbcType="VARCHAR"/>
|
||||||
<result column="organization" property="organization" jdbcType="VARCHAR"/>
|
<result column="organization" property="organization" jdbcType="VARCHAR"/>
|
||||||
<result column="organizational_role" property="organizationalRole" jdbcType="VARCHAR"/>
|
<result column="organizational_role" property="organizationalRole" jdbcType="VARCHAR"/>
|
||||||
|
<result column="last_active" property="lastActive" jdbcType="TIMESTAMP"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<!-- Select all usernames -->
|
<!-- Select all usernames -->
|
||||||
@@ -63,8 +64,8 @@
|
|||||||
<select id="select" resultMap="UserResultMap">
|
<select id="select" resultMap="UserResultMap">
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
user_id,
|
[guacamole_user].user_id,
|
||||||
username,
|
[guacamole_user].username,
|
||||||
password_hash,
|
password_hash,
|
||||||
password_salt,
|
password_salt,
|
||||||
password_date,
|
password_date,
|
||||||
@@ -78,13 +79,16 @@
|
|||||||
full_name,
|
full_name,
|
||||||
email_address,
|
email_address,
|
||||||
organization,
|
organization,
|
||||||
organizational_role
|
organizational_role,
|
||||||
|
MAX(start_date) AS last_active
|
||||||
FROM [guacamole_user]
|
FROM [guacamole_user]
|
||||||
WHERE username IN
|
LEFT JOIN [guacamole_user_history] ON [guacamole_user_history].user_id = [guacamole_user].user_id
|
||||||
|
WHERE [guacamole_user].username IN
|
||||||
<foreach collection="identifiers" item="identifier"
|
<foreach collection="identifiers" item="identifier"
|
||||||
open="(" separator="," close=")">
|
open="(" separator="," close=")">
|
||||||
#{identifier,jdbcType=VARCHAR}
|
#{identifier,jdbcType=VARCHAR}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
GROUP BY [guacamole_user].user_id
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -93,7 +97,7 @@
|
|||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
[guacamole_user].user_id,
|
[guacamole_user].user_id,
|
||||||
username,
|
[guacamole_user].username,
|
||||||
password_hash,
|
password_hash,
|
||||||
password_salt,
|
password_salt,
|
||||||
password_date,
|
password_date,
|
||||||
@@ -107,16 +111,19 @@
|
|||||||
full_name,
|
full_name,
|
||||||
email_address,
|
email_address,
|
||||||
organization,
|
organization,
|
||||||
organizational_role
|
organizational_role,
|
||||||
|
MAX(start_date) AS last_active
|
||||||
FROM [guacamole_user]
|
FROM [guacamole_user]
|
||||||
JOIN [guacamole_user_permission] ON affected_user_id = [guacamole_user].user_id
|
JOIN [guacamole_user_permission] ON affected_user_id = [guacamole_user].user_id
|
||||||
WHERE username IN
|
LEFT JOIN [guacamole_user_history] ON [guacamole_user_history].user_id = [guacamole_user].user_id
|
||||||
|
WHERE [guacamole_user].username IN
|
||||||
<foreach collection="identifiers" item="identifier"
|
<foreach collection="identifiers" item="identifier"
|
||||||
open="(" separator="," close=")">
|
open="(" separator="," close=")">
|
||||||
#{identifier,jdbcType=VARCHAR}
|
#{identifier,jdbcType=VARCHAR}
|
||||||
</foreach>
|
</foreach>
|
||||||
AND [guacamole_user_permission].user_id = #{user.objectID,jdbcType=INTEGER}
|
AND [guacamole_user_permission].user_id = #{user.objectID,jdbcType=INTEGER}
|
||||||
AND permission = 'READ'
|
AND permission = 'READ'
|
||||||
|
GROUP BY [guacamole_user].user_id
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -124,8 +131,8 @@
|
|||||||
<select id="selectOne" resultMap="UserResultMap">
|
<select id="selectOne" resultMap="UserResultMap">
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
user_id,
|
[guacamole_user].user_id,
|
||||||
username,
|
[guacamole_user].username,
|
||||||
password_hash,
|
password_hash,
|
||||||
password_salt,
|
password_salt,
|
||||||
password_date,
|
password_date,
|
||||||
@@ -139,10 +146,13 @@
|
|||||||
full_name,
|
full_name,
|
||||||
email_address,
|
email_address,
|
||||||
organization,
|
organization,
|
||||||
organizational_role
|
organizational_role,
|
||||||
|
MAX(start_date) AS last_active
|
||||||
FROM [guacamole_user]
|
FROM [guacamole_user]
|
||||||
|
LEFT JOIN [guacamole_user_history] ON [guacamole_user_history].user_id = [guacamole_user].user_id
|
||||||
WHERE
|
WHERE
|
||||||
username = #{username,jdbcType=VARCHAR}
|
[guacamole_user].username = #{username,jdbcType=VARCHAR}
|
||||||
|
GROUP BY [guacamole_user].user_id
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user