Skip to content

Commit

Permalink
Merge pull request #65 from payatu/banditamit
Browse files Browse the repository at this point in the history
plain Text User Cred Store
  • Loading branch information
banditAmit authored Jul 18, 2024
2 parents 9148e35 + 640fbff commit 4860b56
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
11 changes: 11 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/qaplug_profiles.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions app/src/main/java/com/BugBazaar/controller/UserAuthSave.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ public class UserAuthSave {
private static final String KEY_PASSWORD = "password";
private static final String keypasscode = "passcode";
private static final String keypasscode_flag = "passcode_flag";
private static final String USER_DATA = "userCred";

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

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

}

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();


}
}
3 changes: 2 additions & 1 deletion app/src/main/java/com/BugBazaar/ui/Signin.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,13 @@ 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) {

sessionManager.setLoggedIn(true);
String randomToken = TokenGenerator.generateRandomToken(64);
userAuthSave.saveUserData( randomToken,isLoggedin);
userAuthSave.saveuserCred(username,password);
// Successful login, do something (e.g., start a new activity)
Toast.makeText(Signin.this, "Login successful!", Toast.LENGTH_SHORT).show();

Expand Down

0 comments on commit 4860b56

Please sign in to comment.