Hi everyone. I’m studying Couchbase Lite (3rd day) and it seems to me very powerful.
Actually there is one particular thing that i can’t understand: login.
I’ve seen Facebook login, custom login with cookies and strange things but… i need to implement a normal login
mechanism. The user opens the app, types in name and password and if such user exists, then he enters in the
MainActivity.
I didn’t find any tutorial or practical example about that.
I want to create a simple application in which a user can be a Student or a Professor. A professor can
create/update/delete notes about his courses. A student can create/update notes about the courses
he is registered to. These rules can be defined inside the sync functions, is it right?
From what i understand, in this context a course can be seen as a channel.
Data model:
- Documents for professors (id, type, name, array of his courses (ids))
- Documents for students (id, type, name, array of courses he is registered to (ids))
?? Documents for notes (id, type, course it belongs to, text) ?? --> probably it is not necessary - Documents for courses (name(id), type, array of notes with title and text)
To make a login mechanism as i’ve said, is it enough to put also the password in the documents of students and professors?
Then when the user put the data and clicks login, i would execute a query against the database that looks for
a student or professor with that combination of name/password.
Note: it should not be a REAL application, it’s just an example.
Note 2: i’m using the default database walrus.
Note 3: i’m reading about Admin REST API, but i didn’t understand from where should i send HTTP requests…
Note 4: Ok i’ve to use “curl” to execute http requests. It’s a bit complicated…!
Update:
Ok i can define users in the serviceconfig.json but…
As i said, my users (students or professors) haven’t just “name” and “password”, so i need documents, and
not just their definition in the config file… i’m very confused.
Note 5: for example, once the user is logged with basic authentication, i need to know if he/she is a professor or a studient to load the correct layout for the Activity.