Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. post("/register", (req, res) -> {
  2.  
  3. WebContext context = new SparkWebContext(req, res);
  4. ProfileManager manager = new ProfileManager(context);
  5.  
  6. // todo - check if authed - if yes - decline
  7. String body = req.body().trim();
  8.  
  9. GsonBuilder gsonBuilder = new GsonBuilder();
  10. gsonBuilder.registerTypeAdapter(RegistrationData.class, new RegistrationDeserializer());
  11. Gson gson = gsonBuilder.create();
  12.  
  13. RegistrationData data;
  14.  
  15. try{
  16. data = gson.fromJson(body, RegistrationData.class);
  17. }catch (JsonSyntaxException ex){
  18. return "fail";
  19. }
  20.  
  21. userService.register(data);
  22.  
  23. return "success " + data.getEmail();
  24. }, json());
  25.  
  26. final CallbackRoute callback = new CallbackRoute(config, null, true);
  27. get("/callback", callback);
  28. post("/callback", callback);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement