update
This commit is contained in:
parent
264e1be827
commit
b53452ba1d
|
@ -6,27 +6,26 @@ public class AppConfig {
|
|||
// 0 = PROD & 1 = QA & 2 = TEST
|
||||
private static int CHAINCODE_IDX = 0;
|
||||
|
||||
|
||||
// ENVIRONMENT
|
||||
public static String getCA_URL(){
|
||||
if(ENV==0){
|
||||
return "http://vps577432.ovh.net:7054";
|
||||
} else {
|
||||
return "http://93.30.148.59:7054";
|
||||
return "http://vps592802.ovh.net:7054";
|
||||
}
|
||||
}
|
||||
public static String getORDERER_URL(){
|
||||
if(ENV==0){
|
||||
return "grpc://vps577432.ovh.net:7050";
|
||||
}else {
|
||||
return "grpc://93.30.148.59:7050";
|
||||
return "grpc://vps592802.ovh.net:7050";
|
||||
}
|
||||
}
|
||||
public static String getPEER_0_URL(){
|
||||
if(ENV==0){
|
||||
return "grpc://vps577432.ovh.net:7051";
|
||||
} else {
|
||||
return "grpc://93.30.148.59:7051";
|
||||
return "grpc://vps592802.ovh.net:7051";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,12 @@ public class UserImplementation {
|
|||
userDao.approveUser(user.getEmail());
|
||||
}
|
||||
|
||||
public Boolean getUserApproval(String user_email) throws Exception {
|
||||
UserDao userDao = new UserDao();
|
||||
User u = userDao.getUserWithEmail(user_email);
|
||||
return u.isApproved();
|
||||
}
|
||||
|
||||
public void deleteUser(User user) throws Exception {
|
||||
TransactionWrapper transactionWrapper = new TransactionWrapper();
|
||||
transactionWrapper.sendTransaction("deleteUser",new String[]{user.getUser_hash()});
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package restService;
|
||||
|
||||
import database.user.User;
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
@ -20,11 +22,6 @@ public class UserResource {
|
|||
Map<String,String> userHashResponse = userImplementation.registerUser(user);
|
||||
|
||||
if(Boolean.parseBoolean(userHashResponse.get("response"))){
|
||||
// TEMPORARY AUTOMATIC APPROVE
|
||||
// user.setUser_hash(userHashResponse.get("user_hash"));
|
||||
// userImplementation.approveUser(user);
|
||||
//
|
||||
|
||||
String r = "{\"response\":\"ok\",\"user_hash\":\""+userHashResponse.get("user_hash")+"\"}";
|
||||
return ResponseEntity.status(HttpStatus.OK).body(r);
|
||||
}else {
|
||||
|
@ -51,6 +48,19 @@ public class UserResource {
|
|||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getApproval", method = RequestMethod.GET, params = {"user_hash","user_email"}, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity getUserApproval(@RequestParam(value = "user_hash") String user_hash, @RequestParam(value = "user_email") String user_email){
|
||||
try{
|
||||
UserImplementation userImplementation = new UserImplementation();
|
||||
Boolean approval = userImplementation.getUserApproval(user_email);
|
||||
String r = "{\"response\":\"ok\",\"approval\":"+approval+"}";
|
||||
return ResponseEntity.status(HttpStatus.OK).body(r);
|
||||
} catch (Exception e){
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/login", method = RequestMethod.POST, produces = "application/json")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public ResponseEntity login(@Valid @RequestBody User user){
|
||||
|
|
|
@ -12,7 +12,45 @@ import java.util.Map;
|
|||
public class UserImplementationTest {
|
||||
private static Logger logger = Logger.getLogger(UserImplementationTest.class);
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void ApproveUser(){
|
||||
BasicConfigurator.configure();
|
||||
String email = "sarah.huet@mail.fr";
|
||||
String user_hash = "$2a$10$ZZNA5dPX/OpR327If/ShluJtJwm6tr7WLjp8CyWLsQQvJ0QUZlzkG";
|
||||
|
||||
User u = new User(email,user_hash);
|
||||
|
||||
UserImplementation userImplementation = new UserImplementation();
|
||||
try{
|
||||
userImplementation.approveUser(u);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void getUserApproval(){
|
||||
BasicConfigurator.configure();
|
||||
String email = "sarah.huet@mail.fr";
|
||||
String user_hash = "$2a$10$ZZNA5dPX/OpR327If/ShluJtJwm6tr7WLjp8CyWLsQQvJ0QUZlzkG";
|
||||
|
||||
User u = new User(email,user_hash);
|
||||
|
||||
UserImplementation userImplementation = new UserImplementation();
|
||||
try{
|
||||
logger.info(userImplementation.getUserApproval(email));
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void RegisterUserWithoutPhone() { //OK
|
||||
BasicConfigurator.configure();
|
||||
|
@ -104,6 +142,7 @@ public class UserImplementationTest {
|
|||
logger.warn("Error: "+e);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue