added tenant name in email templates
handled not accepted eula cannot start transaction
added eula errorcode to grey the start button in frontend
MODIFY
src/async-task/tasks/UsersImportAsyncTask.ts
src/async-task/tasks/UsersImportAsyncTask.ts
@@ -71,16 +71,15 @@ export default class UsersImportAsyncTask extends AbstractAsyncTask {
newUser.email = importedUser.email;
newUser.createdBy = { id: importedUser.importedBy };
newUser.createdOn = importedUser.importedOn;
- newUser.autoActivateAtImport = importedUser.autoActivateAtImport;
+ newUser.status = importedUser.autoActivateAtImport ? UserStatus.ACTIVE : UserStatus.PENDING;
// Save the new User
newUser.id = await UserStorage.saveUser(tenant.id, newUser);
// Role need to be set separately
await UserStorage.saveUserRole(tenant.id, newUser.id, UserRole.BASIC);
// Status need to be set separately
- await UserStorage.saveUserStatus(tenant.id, newUser.id, importedUser.autoActivateAtImport ? UserStatus.ACTIVE : UserStatus.PENDING);
+ await UserStorage.saveUserStatus(tenant.id, newUser.id, newUser.status);
await UserStorage.deleteImportedUser(tenant.id, importedUser.id);
// Handle sending email for reseting password if user auto activated
- if (importedUser.autoActivateAtImport) {
// Init Password info
const resetHash = Utils.generateUUID();
await UserStorage.saveUserPassword(tenant.id, newUser.id, { passwordResetHash: resetHash });
@@ -94,12 +93,10 @@ export default class UsersImportAsyncTask extends AbstractAsyncTask {
newUser,
{
'user': newUser,
+ 'tenantName': tenant.name,
'evseDashboardURL': Utils.buildEvseURL(tenant.subdomain),
'evseDashboardCreatePasswordURL': evseDashboardCreatePasswordURL
});
- } else {
- // TODO : handle an informative email saying you will receive soon an email blabla - can reset password first ??
- }
result.inSuccess++;
} catch (error) {
importedUser.status = ImportStatus.ERROR;

MODIFY
src/server/ocpp/services/OCPPService.ts
src/server/ocpp/services/OCPPService.ts
@@ -389,6 +389,13 @@ export default class OCPPService {
// Check User
const user = await Authorizations.isAuthorizedToStartTransaction(
tenant, chargingStation, startTransaction.tagID, ServerAction.START_TRANSACTION, Action.START_TRANSACTION);
+ if (!user?.eulaAcceptedOn) {
+ throw new BackendError({
+ action: ServerAction.START_TRANSACTION,
+ message: 'User has never accepted the EULA - start transaction refused',
+ module: MODULE_NAME, method: 'authorizeToken',
+ });
+ }
if (user) {
startTransaction.userID = user.id;
}

MODIFY
src/server/rest/v1/service/UserService.ts
src/server/rest/v1/service/UserService.ts
@@ -115,6 +115,10 @@ export default class UserService {
const errorCodes: Array<StartTransactionErrorCode> = [];
// Check Billing errors
await UserService.checkBillingErrorCodes(action, req.tenant, req.user, user, errorCodes);
+ // Add error if EULA are not accepted (use case -> at user import)
+ if (!user.eulaAcceptedOn) {
+ errorCodes.push(StartTransactionErrorCode.EULA_NOT_ACCEPTED);
+ }
res.json({
tag, car, errorCodes,
});

MODIFY
src/types/Transaction.ts
src/types/Transaction.ts
@@ -43,6 +43,7 @@ export enum StartTransactionErrorCode {
BILLING_NO_TAX = 'billing_no_tax', // start transaction is not possible - the tax ID is not set or inconsistent
BILLING_NO_SETTINGS = 'billing_no_settings', // start transaction not possible - billing settings are not set (or partially set)
BILLING_INCONSISTENT_SETTINGS = 'billing_inconsistent_settings', // start transaction not possible - billing settings are inconsistent
+ EULA_NOT_ACCEPTED = 'eula_not_accepted',
}
export default interface Transaction extends AbstractCurrentConsumption {

MODIFY
src/types/UserNotifications.ts
src/types/UserNotifications.ts
@@ -349,6 +349,7 @@ export interface AdminAccountVerificationNotification extends BaseNotification {
export interface UserCreatePassword extends BaseNotification {
user: User;
+ tenantName: string;
evseDashboardURL: string;
evseDashboardCreatePasswordURL: string;
}

added tenant name in email templates
handled not accepted eula cannot start transaction
added eula errorcode to grey the start button in frontend