lemberg / connfa-android

Open Source Android app for Conferences and Events
http://connfa.com
Apache License 2.0
100 stars 111 forks source link

Perform login #20

Open yamila-fraiman opened 7 years ago

yamila-fraiman commented 7 years ago

Hi, i am trying to perform a login but I can't get it working. This is my code in Login Manager. How should I call performLogin in my login activity (I know It shouldn't be in the UI thread)?

RequestConfig config = new RequestConfig();
        config.setResponseFormat(BaseRequest.ResponseFormat.JSON);
        config.setRequestFormat(BaseRequest.RequestFormat.JSON);
        BaseRequest loginRequest = new BaseRequest(BaseRequest.RequestMethod.GET, "http://192.168.1.4:4000/api/v1/auth", config);
        loginRequest.addRequestHeader("username", username);
        loginRequest.addRequestHeader("password", password);
        //loginRequest.setPriority(Request.Priority.IMMEDIATE);
        ResponseData loginResponseData = loginRequest.performRequest(true, queue);
        return loginResponseData;
TarasKunyk commented 7 years ago

Hello, You are right: login command is supposed to be triggered from background thread using Model.getInstance().performLogin(...) call Additionally you can implement access token storing within login manager implementation and add it to each request within applyLoginDataToRequest method (in case if you are not using regular cookie-based session tracking)