Set time zone on login
Should be more reliable.
This commit is contained in:
parent
d2e07630d5
commit
d55dc53ade
4 changed files with 13 additions and 20 deletions
12
vedia.rb
12
vedia.rb
|
|
@ -133,6 +133,7 @@ post '/login' do
|
|||
end
|
||||
session.clear
|
||||
session[:user_id] = user.id
|
||||
session[:timezone] = params[:timezone]
|
||||
redirect '/'
|
||||
else
|
||||
@error = _("Incorrect email or password.")
|
||||
|
|
@ -140,10 +141,6 @@ post '/login' do
|
|||
end
|
||||
end
|
||||
|
||||
post '/timezone' do
|
||||
session[:timezone] = JSON.parse(request.body.read)['timezone']
|
||||
end
|
||||
|
||||
get '/reset' do
|
||||
erb :reset
|
||||
end
|
||||
|
|
@ -641,12 +638,7 @@ helpers do
|
|||
end
|
||||
|
||||
def format_date(timestamp)
|
||||
if session[:timezone]
|
||||
"#{TZInfo::Timezone.get(session[:timezone]).to_local(timestamp).strftime('%F')}"
|
||||
else
|
||||
# Otherwise, format_date fails on first page after login. Not sure why...
|
||||
"#{timestamp.strftime('%F')}"
|
||||
end
|
||||
"#{TZInfo::Timezone.get(session[:timezone]).to_local(timestamp).strftime('%F')}"
|
||||
end
|
||||
|
||||
def format_date_and_time(timestamp)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue