Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- [#6175](https://github.com/apache/trafficcontrol/issues/6175) - POST request to /api/4.0/phys_locations accepts mismatch values for regionName.
- Fixed Traffic Monitor parsing stats_over_http output so that multiple stats for the same underlying delivery service (when the delivery service has more than 1 regex) are properly summed together. This makes the resulting data more accurate in addition to fixing the "new stat is lower than last stat" warnings.
- Traffic Ops: Sanitize username before executing LDAP query
- [#6457](https://github.com/apache/trafficcontrol/issues/6457) - Fix broken user registration and password reset, due to the last_authenticated value being null.
- [#6367](https://github.com/apache/trafficcontrol/issues/6367) - Fix PUT `user/current` to work with v4 User Roles and Permissions
- [#6266](https://github.com/apache/trafficcontrol/issues/6266) - Removed postgresql13-devel requirement for traffic_ops
- [#6446](https://github.com/apache/trafficcontrol/issues/6446) - Revert Traffic Router rollover file pattern to the one previously used in `log4j.properties` with Log4j 1.2
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with this
* work for additional information regarding copyright ownership. The ASF
* licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with this
* work for additional information regarding copyright ownership. The ASF
* licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

UPDATE public.tm_user
SET last_authenticated = now()
WHERE last_authenticated IS NULL;
Comment thread
srijeet0406 marked this conversation as resolved.
13 changes: 13 additions & 0 deletions traffic_ops/traffic_ops_golang/login/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,13 @@ func TokenLoginHandler(db *sqlx.DB, cfg config.Config) http.HandlerFunc {
return
}

_, dbErr := db.Exec(UpdateLoginTimeQuery, username)
if dbErr != nil {
dbErr = fmt.Errorf("unable to update authentication time for user '%s': %w", username, dbErr)
api.HandleErr(w, r, nil, http.StatusInternalServerError, nil, dbErr)
return
}

w.Header().Set(rfc.ContentType, rfc.ApplicationJSON)
api.WriteAndLogErr(w, r, append(respBts, '\n'))

Expand Down Expand Up @@ -372,6 +379,12 @@ func OauthLoginHandler(db *sqlx.DB, cfg config.Config) http.HandlerFunc {
}

if userAllowed && authenticated {
_, dbErr := db.Exec(UpdateLoginTimeQuery, form.Username)
if dbErr != nil {
dbErr = fmt.Errorf("unable to update authentication time for user '%s': %w", form.Username, dbErr)
api.HandleErr(w, r, nil, http.StatusInternalServerError, nil, dbErr)
return
}
httpCookie := tocookie.GetCookie(userId, defaultCookieDuration, cfg.Secrets[0])
http.SetCookie(w, httpCookie)
resp = struct {
Expand Down
30 changes: 23 additions & 7 deletions traffic_portal/app/src/common/api/UserService.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,12 @@ var UserService = function($http, locationUtils, userModel, messageModel, ENV) {
);
};

// todo: change to use query param when it is supported
this.updateUser = function(user) {
return $http.put(ENV.api.unstable + "users/" + user.id, user).then(
this.updateCurrentUser = function(user) {
// We should be using PUT 'user/current' to update the current user
const currUser = { user };
return $http.put(ENV.api.unstable + 'user/current', currUser).then(
function(result) {
if (userModel.user.id === user.id) {
// if you are updating the currently logged in user...
userModel.setUser(user);
}
userModel.setUser(user);
messageModel.setMessages(result.data.alerts, false);
return result;
},
Expand All @@ -100,6 +98,24 @@ var UserService = function($http, locationUtils, userModel, messageModel, ENV) {
);
};

// todo: change to use query param when it is supported
this.updateUser = function(user) {
if (userModel.user.id === user.id) {
return this.updateCurrentUser(user);
} else {
return $http.put(ENV.api.unstable + "users/" + user.id, user).then(
function(result) {
messageModel.setMessages(result.data.alerts, false);
return result;
},
function(err) {
messageModel.setMessages(err.data.alerts, false);
throw err;
}
);
}
};

this.registerUser = function(registration) {
return $http.post(ENV.api.unstable + "users/register", registration).then(
function(result) {
Expand Down
3 changes: 3 additions & 0 deletions traffic_portal/app/src/modules/private/user/UserController.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ var UserController = function($scope, $state, $location, $uibModal, formUtils, l
$scope.user = userModel.user;

$scope.confirmSave = function(user, usernameField) {
if (usernameField === undefined) {
usernameField = user.username;
}
if (usernameField.$dirty) {
var params = {
title: 'Reauthentication Required',
Expand Down