auth via somethingawful cookie
This commit is contained in:
48
notebook.livemd
Normal file
48
notebook.livemd
Normal file
@ -0,0 +1,48 @@
|
||||
# Soemthing Erlang Diagnosix
|
||||
|
||||
## Intro
|
||||
|
||||
Fork this or die!
|
||||
|
||||
```elixir
|
||||
alias SomethingErlang.Accounts.User
|
||||
alias SomethingErlang.Repo
|
||||
alias SomethingErlang.AwfulApi.Client
|
||||
|
||||
:ok
|
||||
```
|
||||
|
||||
```elixir
|
||||
%User{bbuserid: "21234"}
|
||||
|> Repo.insert!()
|
||||
```
|
||||
|
||||
<!-- livebook:{"branch_parent_index":0} -->
|
||||
|
||||
## database
|
||||
|
||||
```elixir
|
||||
for user <- Repo.all(User) do
|
||||
user.email
|
||||
end
|
||||
```
|
||||
|
||||
<!-- livebook:{"branch_parent_index":0} -->
|
||||
|
||||
## client
|
||||
|
||||
```elixir
|
||||
res = Client.login()
|
||||
```
|
||||
|
||||
```elixir
|
||||
cookies = res.headers["set-cookie"]
|
||||
|
||||
for cookie <- cookies, String.starts_with?(cookie, "bb"), into: %{} do
|
||||
cookie
|
||||
|> String.split(";", parts: 2)
|
||||
|> List.first()
|
||||
|> String.split("=")
|
||||
|> then(fn [k, v] -> {String.to_existing_atom(k), v} end)
|
||||
end
|
||||
```
|
Reference in New Issue
Block a user