LocalSessionUtils

The LocalSessionUtils class is useful to manage the local sessions of the user, so manage the credentials of the user and all his/her personal data like profile pic, email and password

Author

N7ghtm4r3 - Tecknobit

Types

Link copied to clipboard
The NovaSession record is useful to store and work with the local sessions

Properties

Link copied to clipboard
val CREATE_SESSIONS_TABLE: String = "CREATE TABLE IF NOT EXISTS sessions (id VARCHAR(32) PRIMARY KEY, token VARCHAR(32) NOT NULL, profile_pic TEXT NOT NULL, name VARCHAR(20) NOT NULL, surname VARCHAR(30) NOT NULL, email VARCHAR(75) NOT NULL, password VARCHAR(32) NOT NULL, host_address VARCHAR(75) NOT NULL, role VARCHAR(8) NOT NULL, is_active BOOL DEFAULT 0, language VARCHAR(2) NOT NULL );"
CREATE_SESSIONS_TABLE the query to create the SESSIONS_TABLE
Link copied to clipboard
val DATABASE_NAME: String = "NovaSessions.db"
DATABASE_NAME the name of the local database
Link copied to clipboard
val SESSIONS_TABLE: String = "sessions"
SESSIONS_TABLE the name of the sessions table

Functions

Link copied to clipboard
Method to change the current active session with a new one specified by the identifier
Link copied to clipboard
open fun changeEmail(newEmail: String)
Method to change the email value of the current session
Link copied to clipboard
open fun changeLanguage(newLanguage: String)
Method to change the language value of the current session
Link copied to clipboard
open fun changePassword(newPassword: String)
Method to change the password value of the current session
Link copied to clipboard
open fun changeProfilePic(profilePic: String)
Method to change the profile pic value of the current session
Link copied to clipboard
abstract fun changeSessionValue(key: String, sessionValue: String)
Method to change a value of the current session
Link copied to clipboard
abstract fun deleteAllSessions()
Method to delete all the local sessions, used when the user executes a logout or the account deletion No-any params required
Link copied to clipboard
abstract fun deleteSession(id: String)
Method to delete a specific local session specified by the identifier of the user in that session
Link copied to clipboard
Method to get the current active local session No-any params required
Link copied to clipboard
Method to get the local session specified by the identifier of the user in that session
Link copied to clipboard
Method to list all the local sessions of the user.
Link copied to clipboard
abstract fun insertSession(id: String, token: String, profilePicUrl: String, name: String, surname: String, email: String, password: String, hostAddress: String, role: NovaUser.Role, language: String)
Method to insert a new session
Link copied to clipboard
Method to set the current active session as inactive No-any params required
Link copied to clipboard
abstract fun setNewActiveSession(id: String)
Method to set as the active session a new session