Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. app.config(['$httpProvider', function($httpProvider) {
  2. $httpProvider.defaults.withCredentials = true;
  3. }]);
  4.  
  5. The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'
  6.  
  7. def authenticate_current_user
  8. head :unauthorized if get_current_user.nil?
  9. end
  10.  
  11. def get_current_user
  12. return nil unless cookies[:auth_headers]
  13. auth_headers = JSON.parse(cookies[:auth_headers])
  14.  
  15. expiration_datetime = DateTime.strptime(auth_headers["expiry"], "%s")
  16. current_user = User.find_by(uid: auth_headers["uid"])
  17.  
  18. if current_user &&
  19. current_user.tokens.has_key?(auth_headers["client"]) &&
  20. expiration_datetime > DateTime.now
  21.  
  22. @current_user = current_user
  23. end
  24. @current_user
  25. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement