Created
December 15, 2015 13:18
-
-
Save aesteve/7052642a5c3454527faf to your computer and use it in GitHub Desktop.
centralize auth logic
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
import static AuthorizationLogic.authorize; | |
authorize(authInfo, user -> { | |
user.greet(); | |
// do what you want to | |
}, failure -> { | |
if (!(failure instanceof AuthorizationException)) { | |
log.error("Something went wrong"); | |
// notify client (503 ?) | |
} else { | |
// context.fail(401); | |
// insult user | |
// ban him... | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment