MCPcopy
hub / github.com/writefreely/writefreely / AuthenticateUser

Function AuthenticateUser

auth.go:18–28  ·  view source on GitHub ↗

AuthenticateUser ensures a user with the given accessToken is valid. Call it before any operations that require authentication or optionally associate data with a user account. Returns an error if the given accessToken is invalid. Otherwise the associated user ID is returned.

(db writestore, accessToken string)

Source from the content-addressed store, hash-verified

16// Returns an error if the given accessToken is invalid. Otherwise the
17// associated user ID is returned.
18func AuthenticateUser(db writestore, accessToken string) (int64, error) {
19 if accessToken == "" {
20 return 0, ErrNoAccessToken
21 }
22 userID := db.GetUserID(accessToken)
23 if userID == -1 {
24 return 0, ErrBadAccessToken
25 }
26
27 return userID, nil
28}

Callers 1

existingPostFunction · 0.85

Calls 1

GetUserIDMethod · 0.65

Tested by

no test coverage detected