Last active
October 18, 2016 11:43
-
-
Save u007/0d36ae3555ed24caafdbaf0d1363f7f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func Auth(c *revel.Controller) bool { | |
if LoggedInCheck() {//write your own | |
return true | |
} | |
email, pass, _ := c.Request.BasicAuth() | |
//login n password | |
//TODO check login here | |
//... | |
if email == "" { | |
//bypass revel to http.Response (c.Response.Out) | |
c.Response.Out.Header().Add("WWW-Authenticate", `Basic realm="MY REALM"`) | |
c.Response.Out.WriteHeader(401) | |
c.Response.Out.Write([]byte("401 Unauthorized\n")) | |
return false | |
} | |
return true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment