Skip to content

Commit

Permalink
fix up CI
Browse files Browse the repository at this point in the history
  • Loading branch information
nmenag committed Dec 26, 2023
1 parent bf366bc commit 155dec4
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 29 deletions.
3 changes: 3 additions & 0 deletions .dialyzer_ignore.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
{"apps/core/lib/core/uploader.ex"}
]
27 changes: 16 additions & 11 deletions apps/core/lib/core/uploader.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ defmodule GoEscuelaLms.Core.GCP.Manager do
"""
require Logger

# @dialyzer {:no_return, {:upload, 2}}

def upload(object, resource) do
conn = connection()
file_name = resource.filename
Expand All @@ -28,17 +30,20 @@ defmodule GoEscuelaLms.Core.GCP.Manager do
bytes
)

case upload_result do
{:ok, %GoogleApi.Storage.V1.Model.Object{} = result} ->
Logger.info("File uploaded to GCP Storage - #{file_name}")
File.close(file_binary)
{:ok, result.etag}

{:error, message} ->
Logger.info("File uploaded fail #{inspect(message)}")
File.close(file_binary)
{:error, message}
end
result =
case upload_result do
{:ok, %GoogleApi.Storage.V1.Model.Object{} = result} ->
Logger.info("File uploaded to GCP Storage - #{file_name}")
File.close(file_binary)
{:ok, result.etag}

{:error, message} ->
Logger.info("File uploaded fail #{inspect(message)}")
File.close(file_binary)
{:error, message}
end

result
end

def connection() do
Expand Down
14 changes: 2 additions & 12 deletions apps/web/lib/web/auth/authorized_plug.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule Web.Auth.AuthorizedPlug do
import Plug.Conn
alias GoEscuelaLms.Core.Schema.User

def is_organizer_authorized(conn, _) do
def organizer_authorized(conn, _) do
case conn.assigns.account |> User.organizer?() do
true ->
conn
Expand All @@ -15,17 +15,7 @@ defmodule Web.Auth.AuthorizedPlug do
end
end

def is_instructor_authorized(conn, _) do
case conn.assigns.account |> User.instructor?() do
true ->
conn

_ ->
Web.FallbackController.call(conn, {:error, :forbidden}) |> halt()
end
end

def is_permit_authorized(conn, _) do
def permit_authorized(conn, _) do
case conn.assigns.account |> User.instructor?() || conn.assigns.account |> User.organizer?() do
true ->
conn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule Web.Activities.ActivitiesController do

alias GoEscuelaLms.Core.Schema.Activity

plug :is_permit_authorized when action in [:create]
plug :permit_authorized when action in [:create]
plug :load_course when action in [:create]
plug :check_enrollment when action in [:create]
plug :load_topic when action in [:create]
Expand Down
2 changes: 1 addition & 1 deletion apps/web/lib/web/controllers/courses/courses_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule Web.Courses.CoursesController do

alias GoEscuelaLms.Core.Schema.{Course, User}

plug :is_organizer_authorized when action in [:create, :update]
plug :organizer_authorized when action in [:create, :update]
plug :load_course when action in [:show, :update]
plug :check_enrollment when action in [:show, :update]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule Web.Enrollments.EnrollmentsController do

alias GoEscuelaLms.Core.Schema.{Enrollment}

plug :is_organizer_authorized when action in [:create]
plug :organizer_authorized when action in [:create]
plug :load_user when action in [:create]
plug :load_course when action in [:create]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defmodule Web.Onboarding.InstitutionInfoController do

alias GoEscuelaLms.Core.Schema.InstitutionInfo

plug :is_organizer_authorized when action in [:show]
plug :organizer_authorized when action in [:show]

def show(conn, _params) do
institution_info = InstitutionInfo.get!()
Expand Down
2 changes: 1 addition & 1 deletion apps/web/lib/web/controllers/topics/topics_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule Web.Topics.TopicsController do

alias GoEscuelaLms.Core.Schema.Topic

plug :is_permit_authorized when action in [:create]
plug :permit_authorized when action in [:create]
plug :load_course when action in [:create]
plug :check_enrollment when action in [:create]
plug :load_topic when action in [:update, :delete]
Expand Down
2 changes: 1 addition & 1 deletion apps/web/lib/web/controllers/users/users_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule Web.Users.UsersController do

alias GoEscuelaLms.Core.Schema.User

plug :is_organizer_authorized when action in [:create]
plug :organizer_authorized when action in [:create]
plug :load_user when action in [:update, :delete]

@create_params %{
Expand Down
1 change: 1 addition & 0 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ defmodule GoEscuelaLms.MixProject do
aliases: aliases(),
test_coverage: [tool: ExCoveralls],
dialyzer: [
ignore_warnings: ".dialyzer_ignore.exs",
plt_core_path: "priv/plts",
plt_local_path: "priv/plts",
plt_add_apps: [:ex_unit]
Expand Down

0 comments on commit 155dec4

Please sign in to comment.