diff --git a/src/apps/persistence/users.clj b/src/apps/persistence/users.clj index 8d8251a4..70e9466a 100644 --- a/src/apps/persistence/users.clj +++ b/src/apps/persistence/users.clj @@ -45,25 +45,15 @@ (defn- insert-login-record "Records when a user logs into the DE." - [user-id ip-address user-agent] + [user-id ip-address] (insert :logins (values (remove-nil-values {:user_id user-id - :ip_address ip-address - :user_agent user-agent})))) + :ip_address ip-address})))) (defn record-login "Records when a user logs into the DE. Returns the recorded login time." - [username ip-address user-agent] - (-> (insert-login-record (get-user-id username) ip-address user-agent) + [username ip-address] + (-> (insert-login-record (get-user-id username) ip-address) (:login_time) (.getTime))) - -(defn record-logout - "Records when a user logs out of the DE." - [username ip-address login-time] - (sql/update :logins - (set-fields {:logout_time (sqlfn :now)}) - (where {:user_id (get-user-id username) - :ip_address ip-address}) - (where {(sqlfn :date_trunc "milliseconds" :login_time) (Timestamp. login-time)}))) diff --git a/src/apps/routes/schemas/user.clj b/src/apps/routes/schemas/user.clj index 1b076116..dbde61c9 100644 --- a/src/apps/routes/schemas/user.clj +++ b/src/apps/routes/schemas/user.clj @@ -17,9 +17,4 @@ (defschema LoginParams (merge SecuredQueryParams - sessions-schema/IPAddrParam - {:user-agent (describe String "The user agent obtained from the original request.")})) - -(defschema LogoutParams - (merge SecuredQueryParams - sessions-schema/LogoutParams)) + sessions-schema/IPAddrParam)) diff --git a/src/apps/routes/users.clj b/src/apps/routes/users.clj index 2e71a33f..b6f2a771 100644 --- a/src/apps/routes/users.clj +++ b/src/apps/routes/users.clj @@ -29,10 +29,4 @@ :summary "User Login Service" :description "Terrain calls this service to record when a user logs in and to fetch user session info." - (ok (users/login current-user params))) - - (POST "/logout" [] - :query [params LogoutParams] - :summary sessions-schema/LogoutSummary - :description sessions-schema/LogoutDocs - (ok (users/logout current-user params)))) + (ok (users/login current-user params)))) diff --git a/src/apps/service/users.clj b/src/apps/service/users.clj index dd696434..7ce685a2 100644 --- a/src/apps/service/users.clj +++ b/src/apps/service/users.clj @@ -12,11 +12,6 @@ (remove-nil-vals (up/for-username username))) (defn login - [{:keys [username] :as current-user} {:keys [ip-address user-agent]}] - {:login_time (up/record-login username ip-address user-agent) + [{:keys [username] :as current-user} {:keys [ip-address]}] + {:login_time (up/record-login username ip-address) :auth_redirect (oauth/get-redirect-uris current-user)}) - -(defn logout - [{:keys [username]} {:keys [ip-address login-time]}] - (up/record-logout username ip-address login-time) - nil)