-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Plugging-in the login component (for now mostly mock-up).
- Loading branch information
Showing
5 changed files
with
108 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Twopenny. (C) MLstate - 2011 | ||
* @author Adam Koprowski | ||
**/ | ||
|
||
package mlstate.twopenny | ||
|
||
import widgets.loginbox | ||
import components.login | ||
|
||
type Login.credentials = | ||
{ login : string | ||
; passwd : string | ||
} | ||
|
||
type Login.private_state = | ||
{ user : option(User.ref) | ||
} | ||
|
||
type Login.public_state = Login.private_state | ||
|
||
type Login.config = CLogin.config(Login.credentials, Login.private_state, | ||
Login.public_state) | ||
|
||
type Login.component = CLogin.t(Login.credentials, Login.private_state, | ||
Login.public_state) | ||
|
||
Login = | ||
|
||
dom_id = "login" | ||
|
||
{{ | ||
|
||
@publish @server authenticate(cred : Login.credentials, state : Login.private_state) | ||
: option(Login.private_state) = | ||
do Log.debug("[LOGIN]", "authentication: [login:{cred.login}, passwd:{cred.passwd}]") | ||
user_ref = User.mk_ref(cred.login) | ||
match User.get(user_ref) with | ||
| {none} -> none | ||
| {some=user} -> | ||
passwd = User.mk_passwd(cred.passwd) | ||
if passwd == user.passwd then | ||
some({user = some(user_ref)}) | ||
else | ||
none | ||
|
||
@private loginbox(onchange : Login.credentials -> void, state : Login.public_state) | ||
: xhtml = | ||
login_action(login, passwd) = onchange(~{login passwd}) | ||
user_opt = Option.map((user_ref -> <>{User.ref_to_string(user_ref)}</>), state.user) | ||
WLoginbox.html(WLoginbox.default_config, dom_id, login_action, user_opt) | ||
|
||
@private login_conf : Login.config = | ||
{ ~authenticate | ||
; get_credential(state : Login.private_state) : Login.public_state = state | ||
; ~loginbox | ||
; on_change(_, _) = void | ||
; dbpath = none | ||
; prelude = none | ||
} | ||
|
||
@private default_state : Login.private_state = | ||
{ user = none } | ||
|
||
init() : Login.component = | ||
CLogin.make(default_state, login_conf) | ||
|
||
html(component : Login.component) : xhtml = | ||
CLogin.html(component) | ||
|
||
}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ msg_factory.opa | |
user.opa | ||
label.opa | ||
utils.opa | ||
login.opa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters