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).

1  
!7
2  
3  
concept AUser {
4  
  S globalID = aLongGlobalID();
5  
  S userName, email, realName;
6  
  S token;
7  
  long lastSeen;
8  
}
9  
10  
cmodule AssistantUsers > DynCRUD<AUser> {
11  
  // API
12  
  
13  
  S userIDForEmail(S email) {
14  
    ret getString globalID(conceptWhereIC(AUser, +email));
15  
  }
16  
  
17  
  S userIDForName(S userName) {
18  
    ret getString globalID(conceptWhereIC(AUser, +userName));
19  
  }
20  
  
21  
  void updateLastSeen(S userID) {
22  
    cset(conceptWhere(AUser, globalID := userID), lastSeen := now());
23  
  }
24  
  
25  
  S registerUser(S email, S passwordHash) {
26  
    if (userIDForEmail(email) != null)
27  
      ret "User exists already";
28  
    if (!isValidEmailAddress(email))
29  
      ret "Not a valid e-mail address";
30  
    if (!isSHA256(passwordHash))
31  
      ret "Internal error";
32  
    AUser user = uniq_sync(AUser, +email);
33  
    dm_call(dm_assistant_passwordsCRUD(), 'savePassword, user.globalID, passwordHash);
34  
    ret "User registered!";
35  
  }
36  
}

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: 305 / 1931
Version history: 9 change(s)
Referenced in: [show references]