Share My Creation [Project Template] User Login Server

Version: 3.10

User Login Server


GitHub: https://github.com/pyhoon/user-login-server-b4j

Clients: [Project Template] [B4X] User Login Client

Description:
  1. This is a user registration and login server.
  2. Includes API for change and reset user password.
  3. Based on Web API Server v3.50 project template.
  4. It is a remake of MySQL API Server (Key + Token) and [B4X] User Login Apps.
  5. By default the access token will expired in 10 minutes. It is renewed using API key. It is similar to JSON Web Token.
  6. Testing can be done locally without setting up email.
Database:
  • SQLite
  • MySQL
Depends on:
You can use LibDownloader to download the correct version of additional libraries.
 

Attachments

  • User Login Server (3.10).b4xtemplate
    424.8 KB · Views: 61
Last edited:

aeric

Expert
Licensed User
Longtime User
Some testing and fixes to support MySQL database. Template updated in post #1.
 

aeric

Expert
Licensed User
Longtime User
Version: 2.00beta1

Based on Web API Server v3.10
Depends on MiniORMUtils v1.14 and WebApiUtils v3.02

Update user-login-client
B4X:
'Public strURL As String = "http://192.168.50.42:17178/web/api/v1/"
Public strURL As String = "http://192.168.50.42:8080/api/v1/"
 

Attachments

  • User Login Server (2.00beta1).b4xtemplate
    445.4 KB · Views: 145
Last edited:

aeric

Expert
Licensed User
Longtime User
Two bugs found and will be fixed in next version.

In User Login Server,
UsersApiHandler
Update to the following code:
B4X:
Private Sub ValidateToken (Token As UserData) As Boolean
    Try
        If Token = Null Or Token.IsInitialized = False Then
            HRM.ResponseCode = 401
            HRM.ResponseError = "Undefine User Token"
            ReturnApiResponse
            Return False
        End If

In User Login Client app,
B4XPageUserProfile
Update to the following code:
B4X:
Sub UpdateProfile
    Try
        Log("[B4XPageUserProfile] UpdateProfile")
        Dim data As Map
        data.Initialize
        data.Put("key", Main.User.ApiKey)
        data.Put("token", Main.User.Token)
        data.Put("user_name", txtUserName.Text.Trim)
        data.Put("user_location", txtUserLocation.Text.Trim)
        Dim job As HttpJob
        job.Initialize("", Me)
        job.PutString(Main.strURL & "users/update-profile", data.As(JSON).ToString)
        job.GetRequest.SetHeader("Authorization", "Bearer " & Main.User.Token)
        Wait For (job) JobDone(job As HttpJob)
 

aeric

Expert
Licensed User
Longtime User
Version: 3.10beta1

Changes:
  • Based on Web API Server template v3.50
  • Depends on MiniORMUtils v2.63
  • User Login Client v2.00beta1
 

aeric

Expert
Licensed User
Longtime User
Version: 3.10

Changes:
  • Based on Web API Server v3.50
  • Depends on MiniORMUtils v2.63, WebApiUtils v3.05
  • User Login Client v2.00
 
Top