package net.davidvoid.thor.lightning.webservice;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by david on 3/20/16.
 */
@RestController
@RequestMapping("/users")
public class UserService {
	
	@RequestMapping(method = RequestMethod.GET)
	public String welcome(HttpServletRequest req) {
		return "hello world";
	}
	
	@RequestMapping(value = "/{username}", method = RequestMethod.PUT)
	public String register() {
	    return null;
	}
	
	@RequestMapping(value = "/{username}", method = RequestMethod.GET)
	public String getUser() {
	    return null;
	}

	@RequestMapping(value = "/{username}/login", method = RequestMethod.POST)
	public String login() {
	    return null;
	}
	
	@RequestMapping(value = "/{username}/logout", method = RequestMethod.POST)
	public String logout() {
	    return null;
	}
	
}

@@ -54,234 +54,621 @@
 ort 
-javax.servlet.http.HttpServletRequest;%0A%0Aimport org.springframework.web.bind.annotation.RequestMapping;%0Aimport org.springframework.web.bind.annotation.RequestMethod;%0Aimport org.springframework.web.bind.annotation.RestController
+net.davidvoid.thor.lightning.service.Auth;%0Aimport net.davidvoid.thor.lightning.service.security.JwtAuthenticationService;%0Aimport net.davidvoid.thor.lightning.util.HttpRequestAssertion;%0Aimport net.davidvoid.thor.lightning.util.MapLiteral;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.web.bind.annotation.*;%0A%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Aimport static net.davidvoid.thor.lightning.util.HttpRequestAssertion.assertStringNotEmpty;%0Aimport static net.davidvoid.thor.lightning.util.HttpRequestAssertion.isTrue
 ;%0A%0A/
@@ -775,19 +775,123 @@
 rvice %7B%0A
-%09%0A%09
+%0A    @Autowired%0A    Auth auth = null;%0A%0A    @Autowired%0A    JwtAuthenticationService jwtService = null;%0A%0A    
 @Request
@@ -918,33 +918,36 @@
 uestMethod.GET)%0A
-%09
+    
 public String we
@@ -982,10 +982,16 @@
 ) %7B%0A
-%09%09
+        
 retu
@@ -1008,22 +1008,27 @@
 world%22;%0A
-%09%7D%0A%09%0A%09
+    %7D%0A%0A    
 @Request
@@ -1086,17 +1086,20 @@
 od.PUT)%0A
-%09
+    
 public S
@@ -1113,29 +1113,32 @@
 egister() %7B%0A
-%09
+   
     
+ 
 return null;
@@ -1130,38 +1130,43 @@
    return null;%0A
-%09%7D%0A%09%0A%09
+    %7D%0A%0A    
 @RequestMapping(
@@ -1216,17 +1216,20 @@
 od.GET)%0A
-%09
+    
 public S
@@ -1242,25 +1242,28 @@
 getUser() %7B%0A
-%09
+    
     return n
@@ -1271,13 +1271,19 @@
 ll;%0A
-%09%7D%0A%0A%09
+    %7D%0A%0A    
 @Req
@@ -1356,57 +1356,377 @@
 ST)%0A
-%09
+    
 public 
+Map%3C
 String
- login() %7B%0A%09    return null;%0A%09%7D%0A%09%0A%09
+, Object%3E login(@PathVariable String username, @RequestBody Map%3CString, Object%3E user) %7B%0A        isTrue(user.size() == 1, %22malformed model%22);%0A        assertStringNotEmpty(user.get(%22password%22), %22password should be given as string%22);%0A%0A        String token = jwtService.getToken(username);%0A        return MapLiteral.map(%22jwt-token%22, token);%0A    %7D%0A%0A    
 @Req
@@ -1796,17 +1796,20 @@
 d.POST)%0A
-%09
+    
 public S
@@ -1829,13 +1829,16 @@
 ) %7B%0A
-%09
+  
     
+  
 retu
@@ -1850,11 +1850,13 @@
 ll;%0A
-%09
+    
 %7D%0A
-%09
 %0A%7D%0A

add login