Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

36
LINES

< > BotCompany Repo | #1023311 // Assistant Users

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 1626K of libraries. Click here for Pure Java version (11297L/59K).

!7

concept AUser {
  S globalID = aLongGlobalID();
  S userName, email, realName;
  S token;
  long lastSeen;
}

cmodule AssistantUsers > DynCRUD<AUser> {
  // API
  
  S userIDForEmail(S email) {
    ret getString globalID(conceptWhereIC(AUser, +email));
  }
  
  S userIDForName(S userName) {
    ret getString globalID(conceptWhereIC(AUser, +userName));
  }
  
  void updateLastSeen(S userID) {
    cset(conceptWhere(AUser, globalID := userID), lastSeen := now());
  }
  
  S registerUser(S email, S passwordHash) {
    if (userIDForEmail(email) != null)
      ret "User exists already";
    if (!isValidEmailAddress(email))
      ret "Not a valid e-mail address";
    if (!isSHA256(passwordHash))
      ret "Internal error";
    AUser user = uniq_sync(AUser, +email);
    dm_call(dm_assistant_passwordsCRUD(), 'savePassword, user.globalID, passwordHash);
    ret "User registered!";
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1023311
Snippet name: Assistant Users
Eternal ID of this version: #1023311/10
Text MD5: 25d8100afde4b49561d82f64fb87f882
Transpilation MD5: 3c0015ab4650959cc9af8a855ae7d48e
Author: stefan
Category: javax / assistants
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-06-11 19:25:58
Source code size: 928 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 302 / 1925
Version history: 9 change(s)
Referenced in: [show references]