-
Notifications
You must be signed in to change notification settings - Fork 1
How To Modify For Your Own Use
If you're interested in modifying this app and in some way incorporating it into your own system, you're absolutely welcome to. Here you will find some extra info and a few things to watch out for during the process.
It's the easy trick we use. We don't actually use realm's authentication features for our users, instead we use a single "owner" account to sign into a single realm. We then have a User model (table) for normal app users and the login screen simply checks whether a user with the given credentials exist in our realm (database). The Admin Tools in the app itself allow adding more users or modifying existing
As far as Realm Object Server goes, there's nothing special going on for Tensuu. Just deploy a server in its default state, and you should be good to go. Once your server is up and running, create a user account to use for your client app.
Create a copy of the Realm configuration sample class and change the credentials info to whatever you made in step 1.
Add some temporary code like the following after the MainPresenter
s SyncUser.currentUser() != null
check:
val user = User()
user.email = "someone@somewhere.com"
user.password = "something"
user.isAdmin = true
user.canModify = true
realm.executeTransaction {
it.copyToRealmOrUpdate(user)
}
Don't forget to remove it once the user is created.
You can user the above method to import your Student
s too:
realm.executeTransaction {
it.createOrUpdateAllFromJson(Student::class.java, assets.open("students.json"))
}
You will need to put your JSON dataset under assets/students.json
. Example:
[
{
"id": 1,
"ssid": "BS000001",
"firstName": "Eliseo",
"lastName": "Swaney",
"grade": "1A",
"floor": 1
},
{
"id": 2,
"ssid": "BS000002",
"firstName": "Eddie",
"lastName": "Čosić",
"grade": "1B",
"floor": 1
}
]
Being written rather quickly for internal use, security honestly didn't receive much attention. Passwords are stored in plain text and Realm isn't encrypted. All users can change anything in the db (e.g. their own or another user's isAdmin
flag) technically. It's just that the UI code applies restrictions.