Can you set up a simple log on system with google endpoints

85 views Asked by At

I have a demo to create which needs to have 3 different log on types. I am not very familiar with PHP and have been using the google app engine with endpoints quite recently.

I am looking to have a simple log on system with a user name and password and i have set up 3 different entity types (admin, merchant and store manager).

The only problem is that all the objectify queries that are created need to be pre defined and cannot search for a user with a username and password matching the correct one specified on the index page which means i can't retrieve the data from the datastore using the API's unless i filter it before had which won't work for a log on system.

1

There are 1 answers

1
jirungaray On

The only problem is that all the objectify queries that are created need to be pre defined and cannot search for a user with a username and password matching the correct one specified on the index page which means i can't retrieve the data from the datastore using the API's unless i filter it before had which won't work for a log on system.

not really sure what you mean by this, nor where you got this info. But implementing a login simple is pretty straightforward using endpoints + objectify. Just query for a user, if the user is not null check for the password and act accordingly.

   @ApiMethod(name = "loginUser", path="login")
    public LoginResponse login(LoginRequest req, HttpServletRequest context) {
        //TODO user search para buscar los usuarios?
        UserAccount user = ofy().load().type(UserAccount.class).filter("username", req.getUsername()).first()
                .now();
        if(user == null){
            // return error
        }
        if(user.getPassword().equals(EncryptionUtils.encrypt(req.getPassword()))){
        //do whatever session handling you like
    }
}