Skip to content
Browse files

Added the verification code generation to the add user function

  • Loading branch information...
1 parent fa21129 commit 1524da23005ad435e17631f62f63c4e74330281e @Joony committed May 20, 2009
View
BIN Mnesia.nitrogen@localhost/DECISION_TAB.LOG
Binary file not shown.
View
BIN Mnesia.nitrogen@localhost/LATEST.LOG
Binary file not shown.
View
BIN ebin/db_users.beam
Binary file not shown.
View
8 src/db_users.erl
@@ -36,11 +36,9 @@ init() ->
%%% add the user to the users database
add_user(Username, EmailAddress, Password) ->
<<PasswordDigest:160>> = crypto:sha(Password),
- Code = string_utils:generate_random_string(32),
- <<CodeDigest:128>> = crypto:md5(Code),
- io:format("CodeDigest: ~w~n", [CodeDigest]),
+ VerificationCode = string_utils:md5_hex(string_utils:generate_random_string(32)),
UsersRow = #users { username=Username, email_address=EmailAddress, password=PasswordDigest, date_joined=erlang:universaltime() },
- VerificationCodeRow = #verification_codes { email_address=EmailAddress, verification_code=Code },
+ VerificationCodeRow = #verification_codes { email_address=EmailAddress, verification_code=VerificationCode },
F = fun() ->
mnesia:write(UsersRow),
mnesia:write(VerificationCodeRow)
@@ -49,7 +47,7 @@ add_user(Username, EmailAddress, Password) ->
{atomic, Val} ->
case validate_user(Username, Password) of
{valid, _ID} ->
- email_utils:send_email_verification_code(EmailAddress, CodeDigest),
+ email_utils:send_email_verification_code(EmailAddress, VerificationCode),
ok;
{aborted, Reason} ->
io:format("Failed to login after registration. Reason: ~s~n", [Reason]),

0 comments on commit 1524da2

Please sign in to comment.
Something went wrong with that request. Please try again.