Add support to ban users from creating sessions

This commit is contained in:
Marcos Lilljedahl
2019-03-05 16:58:20 -03:00
parent 43fe20fb49
commit 5afc852d2b
4 changed files with 43 additions and 1 deletions

View File

@@ -47,6 +47,10 @@ type SessionSetupInstanceConf struct {
func (p *pwd) SessionNew(ctx context.Context, config types.SessionConfig) (*types.Session, error) {
defer observeAction("SessionNew", time.Now())
if u, _ := p.storage.UserGet(config.UserId); u.IsBanned {
return nil, fmt.Errorf("User %s is banned\n", config.UserId)
}
s := &types.Session{}
s.Id = p.generator.NewId()
s.CreatedAt = time.Now()