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

#95 allow user to choose timezone #104

Merged
merged 7 commits into from
Sep 14, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
#95: set default timezone on session after user authentication and af…
…ter editing a user
  • Loading branch information
jmiranda committed Sep 14, 2015
commit 9a54c14c33c2044a14ae5da4ec8ef4ed7195ee8f
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,18 @@ class AuthController {
if (userInstance) {

// FIXME Handle setting timezone based on configuration
TimeZone userTimezone = TimeZone.getTimeZone("America/New_York")
String browserTimezone = request.getParameter("browserTimezone")
if (browserTimezone != null) {
userTimezone = TimeZone.getTimeZone(browserTimezone)
}
TimeZone userTimezone = TimeZone.getTimeZone("America/New_York")
// Check for user's preferred timezone
if (userInstance.timezone) {
userTimezone = TimeZone.getTimeZone(userInstance.timezone)
}
// If there's no user preference timezone, use the browser timezone (login page sets parameter)
else {
String browserTimezone = request.getParameter("browserTimezone")
if (browserTimezone != null) {
userTimezone = TimeZone.getTimeZone(browserTimezone)
}
}
session.timezone = userTimezone;

// Check if user is active -- redirect back to login page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ class UserController {
updateRoles(userInstance, params.locationRolePairs)
}

if (params.timezone) {
session.timezone = TimeZone.getTimeZone(params.timezone)

}

if (!userInstance.hasErrors() && userInstance.save(flush: true)) {
// if this is the current user, update reference to that user in the session
if (session.user.id == userInstance?.id) {
Expand Down