A clean, Markdown-based publishing platform made for writers. Write together, and build a community. https://writefreely.org
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

19 строки
555 B

  1. package writefreely
  2. // AuthenticateUser ensures a user with the given accessToken is valid. Call
  3. // it before any operations that require authentication or optionally associate
  4. // data with a user account.
  5. // Returns an error if the given accessToken is invalid. Otherwise the
  6. // associated user ID is returned.
  7. func AuthenticateUser(db writestore, accessToken string) (int64, error) {
  8. if accessToken == "" {
  9. return 0, ErrNoAccessToken
  10. }
  11. userID := db.GetUserID(accessToken)
  12. if userID == -1 {
  13. return 0, ErrBadAccessToken
  14. }
  15. return userID, nil
  16. }