1
0
mirror of https://github.com/mgerb/classic-wow-forums synced 2026-01-08 08:22:48 +00:00

client/server - update message - update authentication

This commit is contained in:
2018-01-28 14:09:08 -06:00
parent 8191603a2c
commit b3ac9003db
6 changed files with 14 additions and 9 deletions

View File

@@ -6,7 +6,6 @@ import './home.scss';
import header_forms from '../../assets/header-forums.gif';
import support from '../../assets/support.gif';
// import serverstatus from '../../assets/serverstatus.gif';
import uicustomizations from '../../assets/uicustomizations.gif';
import bugs from '../../assets/bugs.gif';
import realms from '../../assets/realms.gif';
@@ -94,9 +93,10 @@ export class Home extends React.Component<Props, State> {
<b>Welcome to the unofficial Classic WoW Forums!</b>
</div>
<p>
This site is made with the intention of providing a web forum
that replicates the World of Warcraft forums as they were
back in 2005.
I created this site with the intention of providing
a fully functional and accurate representation of
the World of Warcraft forums as they were
back in 2005. <Link to={'/t/137/1'}>Please read this first!</Link>
</p>
<p>

View File

@@ -172,7 +172,7 @@ div {
}
.blue-post {
p {
p, li, {
color: $bluePost;
}
}

View File

@@ -1,15 +1,18 @@
defmodule MyApp.Guardian.Auth.Token do
alias MyApp.Guardian
# one month in seconds
defp one_month(), do: 2592000
@spec add_token_and_map_claims(map | {atom, any}) :: {:ok, map} | {:error, String.t}
def add_token_and_map_claims(user) when is_map(user) do
claims = user
|> Map.take([:id, :battletag, :battle_net_id, "access_token"]) # take values from user object to map to claims
|> Map.take([:id, :battletag, :battle_net_id, :access_token]) # take values from user object to map to claims
|> Guardian.add_permissions(get_permissions(user))
# set token expiration to the same as the battlenet token
case Guardian.encode_and_sign(user, claims, ttl: {user["expires_in"], :seconds}) do
case Guardian.encode_and_sign(user, claims, ttl: {Map.get(user, :expires_in) || one_month(), :seconds}) do
{:ok, token, _claims} -> {:ok, Map.merge(user, %{token: token})}
{:error, error} -> {:error, error}
end

View File

@@ -82,7 +82,7 @@ defmodule MyApp.Data.User do
# need to add token back to map because we don't store it in the database
defp add_extra_params({:error, error}, _), do: {:error, error}
defp add_extra_params({:ok, user}, params) do
{:ok, Map.merge(user, params)}
{:ok, Map.merge(user, %{access_token: params["access_token"], expires_in: params["expires_in"]})}
end
defp insert_battlenet_user(params) do

View File

@@ -28,6 +28,7 @@ defmodule MyApp.Data.UserTest do
battletag: "mgerb",
id: user.id,
permissions: "user",
expires_in: nil,
}
# call upsert again with same battletag
@@ -41,6 +42,7 @@ defmodule MyApp.Data.UserTest do
battletag: "mgerb",
id: user.id,
permissions: "user",
expires_in: nil,
character_avatar: nil,
character_class: nil,
character_guild: nil,

View File

@@ -63,7 +63,7 @@ defmodule MyAppWeb.ReplyControllerTest do
# new reply should work
conn = post(new_conn, "/api/reply", %{"content" => "c", "thread_id" => thread_id})
body = conn |> response(200) |> Poison.decode!
conn |> response(200) |> Poison.decode!
end
test "user update reply" do