|  | @ -705,23 +705,25 @@ public class WlyyTokenGranter implements TokenGranter {
 | 
	
		
			
				|  |  |                 throw new InvalidGrantException("Invalid captcha");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String password = parameters.get("password");
 | 
	
		
			
				|  |  |             parameters.remove("password");
 | 
	
		
			
				|  |  | //            parameters.remove("password");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             Authentication userAuth = new UsernamePasswordAuthenticationToken(username, password);
 | 
	
		
			
				|  |  |             ((AbstractAuthenticationToken) userAuth).setDetails(parameters);
 | 
	
		
			
				|  |  |             try {
 | 
	
		
			
				|  |  |                 userAuth = authenticationManager.authenticate(userAuth);
 | 
	
		
			
				|  |  |             SaltUser userDetails = (SaltUser)userDetailsService.loadUserByUsername(username);
 | 
	
		
			
				|  |  |             if(userDetails==null){
 | 
	
		
			
				|  |  |                 throw new InvalidGrantException("Could not authenticate user: " + username);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             catch (AccountStatusException ase) {
 | 
	
		
			
				|  |  |                 throw new InvalidGrantException(ase.getMessage());
 | 
	
		
			
				|  |  |             String pwd = MD5.md5Hex(password+ "{" + userDetails.getSalt() + "}");
 | 
	
		
			
				|  |  |             if(!pwd.equals(userDetails.getPassword())){
 | 
	
		
			
				|  |  |                 throw new InvalidGrantException("Bad credentials");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             catch (BadCredentialsException e) {
 | 
	
		
			
				|  |  |                 throw new InvalidGrantException(e.getMessage());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if (!userDetails.isEnabled()) {
 | 
	
		
			
				|  |  |                 throw new InvalidGrantException("User is disabled");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (userAuth == null || !userAuth.isAuthenticated()) {
 | 
	
		
			
				|  |  |                 throw new InvalidGrantException("Could not authenticate user: " + username);
 | 
	
		
			
				|  |  |             if (!userDetails.isAccountNonLocked()) {
 | 
	
		
			
				|  |  |                 throw new InvalidGrantException("User account is locked");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             Authentication userAuth = new UsernamePasswordAuthenticationToken(username,userDetails.getPassword(),  this.authoritiesMapper.mapAuthorities(userDetails.getAuthorities()));
 | 
	
		
			
				|  |  |             ((AbstractAuthenticationToken) userAuth).setDetails(parameters);
 | 
	
		
			
				|  |  |             OAuth2Request storedOAuth2Request = getRequestFactory().createOAuth2Request(client, tokenRequest);
 | 
	
		
			
				|  |  |             return new OAuth2Authentication(storedOAuth2Request, userAuth);
 | 
	
		
			
				|  |  |         }
 |