Skip to content

Instantly share code, notes, and snippets.

@u007
Last active October 18, 2016 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save u007/0d36ae3555ed24caafdbaf0d1363f7f7 to your computer and use it in GitHub Desktop.
Save u007/0d36ae3555ed24caafdbaf0d1363f7f7 to your computer and use it in GitHub Desktop.
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