mirror of
https://github.com/fiatjaf/khatru.git
synced 2025-03-17 21:32:55 +01:00
GetConnection() and GetAuthed() may return empty.
This commit is contained in:
parent
2a8b704299
commit
3f73a9690a
12
utils.go
12
utils.go
@ -22,11 +22,19 @@ func RequestAuth(ctx context.Context) {
|
||||
}
|
||||
|
||||
func GetConnection(ctx context.Context) *WebSocket {
|
||||
return ctx.Value(wsKey).(*WebSocket)
|
||||
wsi := ctx.Value(wsKey)
|
||||
if wsi != nil {
|
||||
return wsi.(*WebSocket)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetAuthed(ctx context.Context) string {
|
||||
return GetConnection(ctx).AuthedPublicKey
|
||||
conn := GetConnection(ctx)
|
||||
if conn != nil {
|
||||
return conn.AuthedPublicKey
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func GetIP(ctx context.Context) string {
|
||||
|
Loading…
x
Reference in New Issue
Block a user