Skip to content

Instantly share code, notes, and snippets.

@SPY
Created March 21, 2009 10:34
Show Gist options
  • Save SPY/82806 to your computer and use it in GitHub Desktop.
Save SPY/82806 to your computer and use it in GitHub Desktop.
authenticate(Opcode, Data, State) ->
case logon_patterns:auth_request(Data) of
{ok, Build, Account} ->
case account_helper:find_by_name(Account) of
[AccountRecord] ->
H = srp6:challenge(AccountRecord),
NewState = State#logon_state{authenticated=no, account=AccountRecord, hash=H},
{send, logon_patterns:auth_reply(H), NewState};
_ ->
{send, logon_patterns:error(Opcode, account_missing), State}
end;
_ ->
wrong_packet(authenticate, Data),
{send, logon_patterns:error(Opcode, account_missing), State}
end.
auth_request(<<_Err?B, _Size?W?IN, _Game:4?b, _Major?B,
_Middle?B, _Minor?B, Build?W?IN, _Platform:4?b,
_Os:4?b, _Country:4?b, _TimeZone?L?IN, _IP:4?b,
_Length?B, Account:_Length?b>>) ->
{ok, Build, binary_to_list(Account)};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment