Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Commit

Permalink
Fix redis caching of named creds.
Browse files Browse the repository at this point in the history
  • Loading branch information
archaelus committed Dec 12, 2012
1 parent cf8a4e9 commit 67f49d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/logplex_cred.erl
Expand Up @@ -115,9 +115,10 @@ lookup(Id) ->

store(#cred{id = Id,
pass = Pass,
perms = Perms}) ->
perms = Perms,
name = Name}) ->
maybe_report_operation(Id, Perms, store),
redis_helper:store_cred(Id, Pass, perms_to_dict(Perms)).
redis_helper:store_cred(Id, Pass, perms_to_dict(Perms), Name).

destroy(#cred{id = Id}) ->
redis_helper:delete_cred(Id).
Expand Down
11 changes: 7 additions & 4 deletions src/redis_helper.erl
Expand Up @@ -227,15 +227,18 @@ unquarantine_channel(ChannelId) when is_integer(ChannelId) ->

-spec store_cred(ID::binary(),
Pass::binary(),
Perms::[{binary(), binary()}]) ->
Perms::[{binary(), binary()}],
Name::binary()) ->
'ok' | {'error', Reason::term()}.
store_cred(Id, Pass, Perms)
store_cred(Id, Pass, Perms, Name)
when is_binary(Id),
is_binary(Pass),
is_list(Perms) ->
is_list(Perms),
is_binary(Name) ->
Key = iolist_to_binary([<<"cred:">>, Id]),
Cmd = [<<"HMSET">>, Key,
<<"pass">>, Pass
<<"pass">>, Pass,
<<"name">>, Name
| lists:append([ [Perm, Value] || {Perm, Value} <- Perms]) ],
case redo:cmd(config, Cmd) of
<<"OK">> ->
Expand Down

0 comments on commit 67f49d3

Please sign in to comment.