Make Keychain struct public
This commit is contained in:
parent
d8937e89a8
commit
9e43b04f04
4 changed files with 6 additions and 6 deletions
2
app.go
2
app.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)
|
||||
|
|
4
keys.go
4
keys.go
|
@ -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)
|
||||
|
|
2
users.go
2
users.go
|
@ -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…
Add table
Reference in a new issue