aboutsummaryrefslogtreecommitdiff
path: root/contextlib/user.go
blob: 6ef12d6dec9d502c8821fa7b1f84f73a06568c64 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package contextlib

import (
	"context"

	"gitrepo.ru/neonxp/gorum/models"
)

func GetUser(ctx context.Context) *models.User {
	u := ctx.Value(UserKey)
	if u == nil {
		return nil
	}

	user, ok := u.(models.User)
	if !ok {
		return nil
	}

	return &user
}