Make Keychain struct public

pull/102/head
Matt Baer 6 years ago
parent d8937e89a8
commit 9e43b04f04
  1. 2
      app.go
  2. 4
      database.go
  3. 4
      keys.go
  4. 2
      users.go

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

@ -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)

@ -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)

@ -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
}

Loading…
Cancel
Save