Class UserController
java.lang.Object
org.noise_planet.noisemodelling.webserver.UserController
Handle users management
Adapted from tutorial material from
javalin-auth-example
Do not add SQL queries in this class
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionUserController(DataSource serverDataSource, JWTProvider<User> provider, Configuration configuration) -
Method Summary
Modifier and TypeMethodDescriptionvoidabout(io.javalin.http.Context ctx) Render user list HTML pagestatic StringcreateQRCodeImage(URI totpUri) voiddoLogin(io.javalin.http.Context ctx) voiddoRegister(io.javalin.http.Context ctx) Post method of register pagestatic StringformatTotpSecret(String totpSecret) Format totp secret using block 4 of chars to be more readable for the userstatic FilegetDatabaseFile(int userId, String workingDirectory) Retrieves the database file associated with the specified user.getDatabaseFile(User user) Retrieves the database file associated with the specified user.voidindex(io.javalin.http.Context ctx) voidlogin(io.javalin.http.Context ctx) voidlogout(io.javalin.http.Context ctx) voidmemoryStatsStreamOnClose(io.javalin.websocket.WsCloseContext wsCloseContext) Handles WebSocket disconnection for memory stats streaming.voidmemoryStatsStreamOnConnect(io.javalin.websocket.WsConnectContext ctx) Handles WebSocket connection for memory stats streaming.readMessagesArg(io.javalin.http.Context ctx) voidregister(io.javalin.http.Context ctx) Display register pagevoiduserEdit(io.javalin.http.Context ctx) Render user edit HTML pagevoidusers(io.javalin.http.Context ctx) Render user list HTML page
-
Field Details
-
ROLE_FIELD_PREPEND
- See Also:
-
-
Constructor Details
-
UserController
public UserController(DataSource serverDataSource, JWTProvider<User> provider, Configuration configuration)
-
-
Method Details
-
login
public void login(io.javalin.http.Context ctx) -
index
- Throws:
SQLException
-
logout
public void logout(io.javalin.http.Context ctx) -
doLogin
public void doLogin(io.javalin.http.Context ctx) -
doRegister
public void doRegister(io.javalin.http.Context ctx) Post method of register page- Parameters:
ctx- Context
-
createQRCodeImage
- Throws:
IOException
-
formatTotpSecret
Format totp secret using block 4 of chars to be more readable for the user- Parameters:
totpSecret- totpSecret string (multiple of 4- Returns:
- formated totpSecret
-
readMessagesArg
-
register
public void register(io.javalin.http.Context ctx) Display register page- Parameters:
ctx- Context
-
about
public void about(io.javalin.http.Context ctx) Render user list HTML page- Parameters:
ctx- web context
-
users
public void users(io.javalin.http.Context ctx) Render user list HTML page- Parameters:
ctx- web context
-
userEdit
public void userEdit(io.javalin.http.Context ctx) Render user edit HTML page- Parameters:
ctx- web context
-
memoryStatsStreamOnConnect
public void memoryStatsStreamOnConnect(io.javalin.websocket.WsConnectContext ctx) Handles WebSocket connection for memory stats streaming.- Parameters:
ctx- the WebSocket connect context
-
memoryStatsStreamOnClose
public void memoryStatsStreamOnClose(io.javalin.websocket.WsCloseContext wsCloseContext) Handles WebSocket disconnection for memory stats streaming.- Parameters:
wsCloseContext- the WebSocket close context
-
getDatabaseFile
Retrieves the database file associated with the specified user.- Parameters:
user- The user for whom the database file is being retrieved.- Returns:
- A File instance representing the user's database file.
-
getDatabaseFile
Retrieves the database file associated with the specified user.- Parameters:
userId- The identifier of the user for whom the database file is being retrieved.workingDirectory- The working directory where the database file is located.- Returns:
- A File instance representing the user's database file.
-