Skip to content
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [2.20.0] - 2023-02-21

- Dashboard Recipe Interface

## [2.19.0] - 2022-11-07

- Updates version so that new plugin versions can only be used by new core versions due to dependency changes.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id 'java-library'
}

version = "2.19.0"
version = "2.20.0"

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public enum RECIPE_ID {

EMAIL_PASSWORD("emailpassword"), THIRD_PARTY("thirdparty"), SESSION("session"),
EMAIL_VERIFICATION("emailverification"), JWT("jwt"), PASSWORDLESS("passwordless"), USER_METADATA("usermetadata"),
USER_ROLES("userroles"), USER_ID_MAPPING("useridmapping");
USER_ROLES("userroles"), USER_ID_MAPPING("useridmapping"), DASHBOARD("dashboard");

private final String name;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.supertokens.pluginInterface.dashboard;

public class DashboardSessionInfo {
public String userId;
public String sessionId;
public long timeCreated;
public long expiry;

public DashboardSessionInfo(String userId, String sessionId, long timeCreated, long expiry) {
this.userId = userId;
this.sessionId = sessionId;
this.timeCreated = timeCreated;
this.expiry = expiry;
}

public boolean equals(Object other) {
if (other instanceof DashboardSessionInfo) {
DashboardSessionInfo otherSessionInfo = (DashboardSessionInfo) other;
return otherSessionInfo.userId.equals(this.userId) && otherSessionInfo.timeCreated == this.timeCreated
&& otherSessionInfo.sessionId.equals(this.sessionId) && otherSessionInfo.expiry == this.expiry;
}
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.supertokens.pluginInterface.dashboard;

import io.supertokens.pluginInterface.Storage;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.dashboard.exceptions.DuplicateEmailException;
import io.supertokens.pluginInterface.dashboard.exceptions.DuplicateUserIdException;
import io.supertokens.pluginInterface.dashboard.exceptions.UserIdNotFoundException;

public interface DashboardStorage extends Storage {

void createNewDashboardUser(DashboardUser userInfo) throws StorageQueryException, DuplicateUserIdException, DuplicateEmailException;

DashboardUser getDashboardUserByEmail(String email) throws StorageQueryException;

DashboardUser getDashboardUserByUserId(String userId) throws StorageQueryException;

DashboardUser[] getAllDashboardUsers() throws StorageQueryException;

boolean deleteDashboardUserWithUserId(String userId) throws StorageQueryException;

void createNewDashboardUserSession(String userId, String sessionId, long timeCreated, long expiry) throws StorageQueryException, UserIdNotFoundException;

DashboardSessionInfo[] getAllSessionsForUserId(String userId) throws StorageQueryException;

DashboardSessionInfo getSessionInfoWithSessionId(String sessionId) throws StorageQueryException;

boolean revokeSessionWithSessionId(String sessionId) throws StorageQueryException;

void revokeExpiredSessions() throws StorageQueryException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.supertokens.pluginInterface.dashboard;

public class DashboardUser {
public final String email;
public String userId;
public long timeJoined;

// using transient, we tell Gson not to include this when creating a JSON
public transient final String passwordHash;

public DashboardUser(String userId, String email, String passwordHash, long timeJoined) {
this.userId = userId;
this.timeJoined = timeJoined;
this.email = email;
this.passwordHash = passwordHash;
}

public boolean equals(Object other) {
if (other instanceof DashboardUser) {
DashboardUser otherUserInfo = (DashboardUser) other;
return otherUserInfo.email.equals(this.email) && otherUserInfo.passwordHash.equals(this.passwordHash)
&& otherUserInfo.userId.equals(this.userId) && otherUserInfo.timeJoined == this.timeJoined;
}
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.supertokens.pluginInterface.dashboard.exceptions;

public class DashboardException extends Exception {
private static final long serialVersionUID = -8913929332291559225L;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.supertokens.pluginInterface.dashboard.exceptions;

public class DuplicateEmailException extends DashboardException{
private static final long serialVersionUID = -5348162233516164406L;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package io.supertokens.pluginInterface.dashboard.exceptions;

public class DuplicateUserIdException extends DashboardException {
private static final long serialVersionUID = -7629139375718589642L;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package io.supertokens.pluginInterface.dashboard.exceptions;

public class UserIdNotFoundException extends DashboardException {
private static final long serialVersionUID = 5010231597247117722L;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.supertokens.pluginInterface.dashboard.sqlStorage;

import io.supertokens.pluginInterface.dashboard.DashboardStorage;
import io.supertokens.pluginInterface.dashboard.exceptions.DuplicateEmailException;
import io.supertokens.pluginInterface.dashboard.exceptions.UserIdNotFoundException;
import io.supertokens.pluginInterface.exceptions.StorageQueryException;
import io.supertokens.pluginInterface.sqlStorage.SQLStorage;
import io.supertokens.pluginInterface.sqlStorage.TransactionConnection;

public interface DashboardSQLStorage extends DashboardStorage, SQLStorage {

void updateDashboardUsersEmailWithUserId_Transaction(TransactionConnection con, String userId, String newEmail) throws StorageQueryException, DuplicateEmailException, UserIdNotFoundException;

void updateDashboardUsersPasswordWithUserId_Transaction(TransactionConnection con, String userId, String newPassword) throws StorageQueryException, UserIdNotFoundException;

}