Skip to content

Commit

Permalink
v0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
essenciary committed Oct 13, 2020
1 parent 64fe263 commit baf275a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GenieAuthentication"
uuid = "e115e502-7e3a-11e9-29b2-aba8be6c6778"
authors = ["Adrian Salceanu <e@essenciary.com>"]
version = "0.5"
version = "0.6"

[deps]
Genie = "c43c736e-a2d1-11e8-161f-af95117fbd1e"
Expand All @@ -10,5 +10,5 @@ SearchLight = "340e8cb6-72eb-11e8-37ce-c97ebeb32050"

[compat]
Genie = "1"
SearchLight = "0.20"
julia = "1"
SearchLight = "0.21"
julia = "1"
12 changes: 7 additions & 5 deletions files/app/resources/authentication/AuthenticationController.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,21 @@ end

function register()
try
user = SearchLight.save!(User( username = Genie.Router.@params(:username),
password = Genie.Router.@params(:password) |> Users.hash_password,
name = Genie.Router.@params(:name),
email = Genie.Router.@params(:email)))
user = User(username = Genie.Router.@params(:username),
password = Genie.Router.@params(:password) |> Users.hash_password,
name = Genie.Router.@params(:name),
email = Genie.Router.@params(:email)) |> SearchLight.save!

GenieAuthentication.authenticate(user.id, Genie.Sessions.session(Genie.Router.@params))

"Registration successful"
catch ex
@error ex

if hasfield(typeof(ex), :msg)
Genie.Flash.flash(ex.msg)
else
rethrow(ex)
Genie.Flash.flash(string(ex))
end

Genie.Renderer.redirect(:show_register)
Expand Down
19 changes: 9 additions & 10 deletions files/app/resources/users/Users.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@ Base.@kwdef mutable struct User <: AbstractModel
password::String = ""
name::String = ""
email::String = ""

### VALIDATION
# validator::ModelValidator = ModelValidator([
# ValidationRule(:username, UsersValidator.not_empty),
# ValidationRule(:username, UsersValidator.unique),
# ValidationRule(:password, UsersValidator.not_empty),
# ValidationRule(:email, UsersValidator.not_empty),
# ValidationRule(:email, UsersValidator.unique),
# ValidationRule(:name, UsersValidator.not_empty)
# ])
end

Validation.validator(u::Type{User}) = ModelValidator([
ValidationRule(:username, UsersValidator.not_empty),
ValidationRule(:username, UsersValidator.unique),
ValidationRule(:password, UsersValidator.not_empty),
ValidationRule(:email, UsersValidator.not_empty),
ValidationRule(:email, UsersValidator.unique),
ValidationRule(:name, UsersValidator.not_empty)
])

function hash_password(password::String)
sha256(password) |> bytes2hex
end
Expand Down

4 comments on commit baf275a

@essenciary
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/22903

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.0 -m "<description of version>" baf275a2b785341f929c3cdc06d61f1b3a8cdd65
git push origin v0.6.0

@essenciary
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/22903

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.0 -m "<description of version>" baf275a2b785341f929c3cdc06d61f1b3a8cdd65
git push origin v0.6.0

Please sign in to comment.