1
0
mirror of https://github.com/writeas/writefreely synced 2025-02-09 13:08:41 +01:00

Make Keychain struct public

This commit is contained in:
Matt Baer 2019-05-12 17:20:24 -04:00
parent d8937e89a8
commit 9e43b04f04
4 changed files with 6 additions and 6 deletions

2
app.go
View File

@ -68,7 +68,7 @@ type App struct {
db *datastore
cfg *config.Config
cfgFile string
keys *keychain
keys *Keychain
sessionStore *sessions.CookieStore
formDecoder *schema.Decoder

View File

@ -44,7 +44,7 @@ var (
type writestore interface {
CreateUser(*User, string) error
UpdateUserEmail(keys *keychain, userID int64, email string) error
UpdateUserEmail(keys *Keychain, userID int64, email string) error
UpdateEncryptedUserEmail(int64, []byte) error
GetUserByID(int64) (*User, error)
GetUserForAuth(string) (*User, error)
@ -219,7 +219,7 @@ func (db *datastore) CreateUser(u *User, collectionTitle string) error {
// FIXME: We're returning errors inconsistently in this file. Do we use Errorf
// for returned value, or impart?
func (db *datastore) UpdateUserEmail(keys *keychain, userID int64, email string) error {
func (db *datastore) UpdateUserEmail(keys *Keychain, userID int64, email string) error {
encEmail, err := data.Encrypt(keys.emailKey, email)
if err != nil {
return fmt.Errorf("Couldn't encrypt email %s: %s\n", email, err)

View File

@ -30,7 +30,7 @@ var (
cookieKeyPath = filepath.Join(keysDir, "cookies_enc.aes256")
)
type keychain struct {
type Keychain struct {
emailKey, cookieAuthKey, cookieKey []byte
}
@ -42,7 +42,7 @@ func initKeyPaths(app *App) {
func initKeys(app *App) error {
var err error
app.keys = &keychain{}
app.keys = &Keychain{}
if debugging {
log.Info(" %s", emailKeyPath)

View File

@ -79,7 +79,7 @@ type (
// EmailClear decrypts and returns the user's email, caching it in the user
// object.
func (u *User) EmailClear(keys *keychain) string {
func (u *User) EmailClear(keys *Keychain) string {
if u.clearEmail != "" {
return u.clearEmail
}