Commit 69364ec2 authored by Eric Chiang's avatar Eric Chiang

Merge pull request #403 from ericchiang/db_errors

db: print better error messages for invalid input
parents ed89be44 5c5df23a
......@@ -100,9 +100,13 @@ func NewClientIdentityRepoFromClients(dbm *gorp.DbMap, clients []oidc.ClientIden
defer tx.Rollback()
exec := repo.executor(tx)
for _, c := range clients {
if c.Credentials.Secret == "" {
return nil, fmt.Errorf("client %q has no secret", c.Credentials.ID)
}
dec, err := base64.URLEncoding.DecodeString(c.Credentials.Secret)
if err != nil {
return nil, err
return nil, fmt.Errorf("client secrets must be base64 decodable. See issue #337. Please consider replacing %q with %q",
c.Credentials.Secret, base64.URLEncoding.EncodeToString([]byte(c.Credentials.Secret)))
}
cm, err := newClientIdentityModel(c.Credentials.ID, dec, &c.Metadata)
if err != nil {
......
......@@ -451,6 +451,12 @@ func (u *userModel) user() (user.User, error) {
}
func newUserModel(u *user.User) (*userModel, error) {
if u.ID == "" {
return nil, fmt.Errorf("user is missing ID field")
}
if u.Email == "" {
return nil, fmt.Errorf("user %s is missing email field", u.ID)
}
um := userModel{
ID: u.ID,
DisplayName: u.DisplayName,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment