mirror of
https://github.com/miniflux/v2.git
synced 2024-09-30 06:11:22 +02:00
Show last login and session creation date in current timezone
This commit is contained in:
parent
5185bf0c7e
commit
609c57332e
@ -100,6 +100,7 @@ func (c *Controller) Users(ctx *handler.Context, request *handler.Request, respo
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
users.UseTimezone(ctx.UserTimezone())
|
||||||
response.JSON().Standard(users)
|
response.JSON().Standard(users)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,6 +128,7 @@ func (c *Controller) UserByID(ctx *handler.Context, request *handler.Request, re
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
user.UseTimezone(ctx.UserTimezone())
|
||||||
response.JSON().Standard(user)
|
response.JSON().Standard(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@ package model
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/miniflux/miniflux/timezone"
|
||||||
)
|
)
|
||||||
|
|
||||||
// User represents a user in the system.
|
// User represents a user in the system.
|
||||||
@ -99,5 +101,19 @@ func (u *User) Merge(override *User) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UseTimezone converts last login date to the given timezone.
|
||||||
|
func (u *User) UseTimezone(tz string) {
|
||||||
|
if u.LastLoginAt != nil {
|
||||||
|
*u.LastLoginAt = timezone.Convert(tz, *u.LastLoginAt)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Users represents a list of users.
|
// Users represents a list of users.
|
||||||
type Users []*User
|
type Users []*User
|
||||||
|
|
||||||
|
// UseTimezone converts last login timestamp of all users to the given timezone.
|
||||||
|
func (u Users) UseTimezone(tz string) {
|
||||||
|
for _, user := range u {
|
||||||
|
user.UseTimezone(tz)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -4,8 +4,12 @@
|
|||||||
|
|
||||||
package model
|
package model
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
import "fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/miniflux/miniflux/timezone"
|
||||||
|
)
|
||||||
|
|
||||||
// UserSession represents a user session in the system.
|
// UserSession represents a user session in the system.
|
||||||
type UserSession struct {
|
type UserSession struct {
|
||||||
@ -17,9 +21,21 @@ type UserSession struct {
|
|||||||
IP string
|
IP string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *UserSession) String() string {
|
func (u *UserSession) String() string {
|
||||||
return fmt.Sprintf(`ID="%d", UserID="%d", IP="%s", Token="%s"`, s.ID, s.UserID, s.IP, s.Token)
|
return fmt.Sprintf(`ID="%d", UserID="%d", IP="%s", Token="%s"`, u.ID, u.UserID, u.IP, u.Token)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UseTimezone converts creation date to the given timezone.
|
||||||
|
func (u *UserSession) UseTimezone(tz string) {
|
||||||
|
u.CreatedAt = timezone.Convert(tz, u.CreatedAt)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserSessions represents a list of sessions.
|
// UserSessions represents a list of sessions.
|
||||||
type UserSessions []*UserSession
|
type UserSessions []*UserSession
|
||||||
|
|
||||||
|
// UseTimezone converts creation date of all sessions to the given timezone.
|
||||||
|
func (u UserSessions) UseTimezone(tz string) {
|
||||||
|
for _, session := range u {
|
||||||
|
session.UseTimezone(tz)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -11,11 +11,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/lib/pq/hstore"
|
|
||||||
|
|
||||||
"github.com/miniflux/miniflux/model"
|
"github.com/miniflux/miniflux/model"
|
||||||
"github.com/miniflux/miniflux/timer"
|
"github.com/miniflux/miniflux/timer"
|
||||||
|
|
||||||
|
"github.com/lib/pq/hstore"
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ func (c *Controller) ShowSessions(ctx *handler.Context, request *handler.Request
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sessions.UseTimezone(user.Timezone)
|
||||||
response.HTML().Render("sessions", args.Merge(tplParams{
|
response.HTML().Render("sessions", args.Merge(tplParams{
|
||||||
"sessions": sessions,
|
"sessions": sessions,
|
||||||
"currentSessionToken": ctx.UserSessionToken(),
|
"currentSessionToken": ctx.UserSessionToken(),
|
||||||
|
@ -34,6 +34,7 @@ func (c *Controller) ShowUsers(ctx *handler.Context, request *handler.Request, r
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
users.UseTimezone(user.Timezone)
|
||||||
response.HTML().Render("users", args.Merge(tplParams{
|
response.HTML().Render("users", args.Merge(tplParams{
|
||||||
"users": users,
|
"users": users,
|
||||||
"menu": "settings",
|
"menu": "settings",
|
||||||
|
Loading…
Reference in New Issue
Block a user