mirror of
https://git.phreedom.club/localhost_frssoft/bloat.git
synced 2024-11-01 02:57:17 +00:00
localhost_frssoft
f9702f81a9
Patch from: https://git.freesoftwareextremist.com/bloat/commit/?id=887ed241d64ba5db3fd3d87194fb5595e5ad7d73 Patch description: Use cookies for session Remove the server side session storage and store all the session related data in the client side cookies. This decreases the exposure of the auth tokens. It also simplifies the installation process as bloat no longer requires write access to the filesystem. This is a breaking change, all the existing sessions will stop working.
53 lines
1.7 KiB
Go
53 lines
1.7 KiB
Go
package model
|
|
|
|
type Session struct {
|
|
ID string `json:"id,omitempty"`
|
|
UserID string `json:"uid,omitempty"`
|
|
Instance string `json:"ins,omitempty"`
|
|
ClientID string `json:"cid,omitempty"`
|
|
ClientSecret string `json:"cs,omitempty"`
|
|
AccessToken string `json:"at,omitempty"`
|
|
CSRFToken string `json:"csrf,omitempty"`
|
|
Settings Settings `json:"sett,omitempty"`
|
|
}
|
|
|
|
func (s Session) IsLoggedIn() bool {
|
|
return len(s.AccessToken) > 0
|
|
}
|
|
|
|
type Settings struct {
|
|
DefaultVisibility string `json:"dv,omitempty"`
|
|
DefaultFormat string `json:"df,omitempty"`
|
|
CopyScope bool `json:"cs,omitempty"`
|
|
ThreadInNewTab bool `json:"tnt,omitempty"`
|
|
HideAttachments bool `json:"ha,omitempty"`
|
|
MaskNSFW bool `json:"mn,omitempty"`
|
|
NotificationInterval int `json:"ni,omitempty"`
|
|
FluorideMode bool `json:"fm,omitempty"`
|
|
DarkMode bool `json:"dm,omitempty"`
|
|
AntiDopamineMode bool `json:"adm,omitempty"`
|
|
HideUnsupportedNotifs bool `json:"hun,omitempty"`
|
|
InstanceEmojiFilter string `json:"iemojfilter,omitempty"`
|
|
AddReactionsFilter string `json:"reactionfilter,omitempty"`
|
|
CSS string `json:"css,omitempty"`
|
|
}
|
|
|
|
func NewSettings() *Settings {
|
|
return &Settings{
|
|
DefaultVisibility: "public",
|
|
DefaultFormat: "",
|
|
CopyScope: true,
|
|
ThreadInNewTab: false,
|
|
HideAttachments: false,
|
|
MaskNSFW: true,
|
|
NotificationInterval: 0,
|
|
FluorideMode: false,
|
|
DarkMode: false,
|
|
AntiDopamineMode: false,
|
|
HideUnsupportedNotifs: false,
|
|
InstanceEmojiFilter: "",
|
|
AddReactionsFilter: "",
|
|
CSS: "",
|
|
}
|
|
}
|