Advertisement
Guest User

Untitled

a guest
Sep 26th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. $scope.addUser = function () {
  2. $scope.userData = {
  3. email: $scope.user.email,
  4. password: $scope.user.password
  5. };
  6.  
  7. auth.signup($scope.userData, successAuth, function (error) {
  8. $rootScope.error = error;
  9. });
  10. };
  11.  
  12. myApp.service('auth', function($http){
  13. return {
  14. signup: function(data,success, error){
  15. //API call to save new user
  16. $http.post('mvc-dispatcher/registration', data).success(success).error(error);
  17. }
  18. };
  19. });
  20.  
  21. @RestController
  22. public class UserController {
  23. @Autowired
  24. private UserService userService;
  25.  
  26. @Autowired
  27. private SecurityService securityService;
  28.  
  29. @Autowired
  30. private UserValidator userValidator;
  31.  
  32. @RequestMapping(value = "/registration", consumes = "application/json", headers = "content-type=application/x-www-form-urlencoded")
  33. public void registration(@RequestBody User userBean) {
  34. User myUser = new User();
  35. System.out.println("register");
  36. System.out.println("name: " + userBean.getUsername());
  37. userService.saveUser(userBean); // how to save user here?
  38. }
  39. }
  40.  
  41. //user repository
  42.  
  43. public interface UserRepository extends JpaRepository<User, Long> {
  44. User findByUsername(String username);
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement