Skip to content

Commit

Permalink
added fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
banditAmit committed Jul 28, 2024
1 parent 6b4df70 commit 18fd1f6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
15 changes: 14 additions & 1 deletion app/src/main/java/com/BugBazaar/controller/UserAuthSave.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@ public class UserAuthSave {
private static final String KEY_USERNAME = "username";
private static final String KEY_PASSWORD = "password";
private static final String keypasscode = "passcode";
private static final String USER_DATA = "userCred";
private static SharedPreferences sharedPreferences1;

private static final String keypasscode_flag = "passcode_flag";

private static SharedPreferences sharedPreferences;
private SessionManager sessionManager; // Move the initialization to a constructor

public UserAuthSave(Context context) {
sharedPreferences = context.getSharedPreferences(USER_PREFERENCES, Context.MODE_PRIVATE);
sessionManager = new SessionManager(context); // Initialize SessionManager in the constructor
sessionManager = new SessionManager(context);
sharedPreferences1 = context.getSharedPreferences(USER_DATA, Context.MODE_PRIVATE);// Initialize SessionManager in the constructor
}

public void saveUserData(String randomToken, boolean loggedIn) {
Expand Down Expand Up @@ -64,4 +68,13 @@ public static String getSavedPassword() {
public static boolean isLoggedIn() {
return sharedPreferences.getBoolean(KEY_LOGGED_IN, false);
}

public void saveuserCred(String username, String password) {
SharedPreferences.Editor editor = sharedPreferences1.edit();
editor.putString("username", username);
editor.putString("password", password);
editor.apply();


}
}
6 changes: 4 additions & 2 deletions app/src/main/java/com/BugBazaar/ui/Signin.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ public void onClick(View v) {
//This will fetch hex username and password from CredentialLoader and compare it with user provided values class.
// It will return true if values are correct. Will return false if values are incorrect.
boolean isLoggedin= loginController.validateLogin(username, password);
String randomToken = TokenGenerator.generateRandomToken(64);

if (isLoggedin==true) {

String randomToken = TokenGenerator.generateRandomToken(64);
sessionManager.setLoggedIn(true);
userAuthSave.saveUserData( randomToken,isLoggedin);
userAuthSave.saveuserCred(username,password);
sessionManager.setLoggedIn(true);
userAuthSave.saveUserData( randomToken,isLoggedin);
// Successful login, do something (e.g., start a new activity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

public class TermsAndConditionsActivity extends AppCompatActivity {
WebView webView;
private SessionManager sessionManager;

private String webViewUrl;

Expand Down Expand Up @@ -77,7 +78,7 @@ else if (webViewUrl.endsWith(".bugbazaar.com")){
}

private String getsessionid() {
return String.valueOf(UUID.randomUUID());
return sessionManager.getUserToken();
}

private class JavaScriptInterface {
Expand Down

0 comments on commit 18fd1f6

Please sign in to comment.