Further work on web interface.

This commit is contained in:
Jonathan Bernard
2011-02-14 09:01:32 -06:00
parent 19fc37c772
commit ddc12cec64
6 changed files with 35 additions and 15 deletions

View File

@ -4,9 +4,13 @@
pwd_salt,
name,
email,
join_date
join_date%,
% ext_data % other extensible data
}).
% ts_user.ext_data can be:
% [{last_timeline, TimelineId}]
-record(ts_timeline, {
ref, % {username, timelineid}
created,% {{year, month, day}, {hour, minute, second}}

View File

@ -10,16 +10,23 @@ create_table(TableOpts) ->
TableOpts ++ [{attributes, record_info(fields, ts_user)},
{type, ordered_set}]).
% expects the password in clear
new(UR = #ts_user{}) ->
case mnesia:dirty_read(ts_user, UR#ts_user.username) of
[ExistingRecord] -> {error, {record_exists, ExistingRecord}};
[] -> mnesia:dirty_write(hash_input_record(UR))
end.
update(UR = #ts_user{}) ->
update(UR = #ts_user{}) ->
case mnesia:dirty_read(ts_user, UR#ts_user.username) of
[] -> no_record;
[_Record] -> mnesia:dirty_write(hash_input_record(UR))
[Record] ->
UpdatedRecord = ts_common:update_record(Record, UR),
HashedRecord = case UR#ts_user.password of
undefined -> UpdatedRecord;
_Password -> hash_input_record(UpdatedRecord)
end.
mnesia:dirty_write(HashedRecord)
end.
lookup(Username) ->