Skip to content

Commit

Permalink
v0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
essenciary committed Oct 12, 2020
1 parent 4b39881 commit 64fe263
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 71 deletions.
2 changes: 1 addition & 1 deletion 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.4.2"
version = "0.5"

[deps]
Genie = "c43c736e-a2d1-11e8-161f-af95117fbd1e"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module AuthenticationController
using Genie, Genie.Renderer, Genie.Renderer.Html, Genie.Router
using SearchLight
using GenieAuthentication
using ViewHelper
using Users
using Logging

Expand Down Expand Up @@ -37,7 +38,7 @@ end

function register()
try
user = SearchLight.save!!(User( username = Genie.Router.@params(:username),
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)))
Expand All @@ -46,7 +47,11 @@ function register()

"Registration successful"
catch ex
Genie.Flash.flash(ex.msg)
if hasfield(typeof(ex), :msg)
Genie.Flash.flash(ex.msg)
else
rethrow(ex)
end

Genie.Renderer.redirect(:show_register)
end
Expand Down
82 changes: 14 additions & 68 deletions files/app/resources/users/Users.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,77 +5,23 @@ using SHA

export User

mutable struct User <: AbstractModel
### INTERNALS
_table_name::String
_id::String
_serializable::Vector{Symbol}

Base.@kwdef mutable struct User <: AbstractModel
### FIELDS
id::DbId
username::String
password::String
name::String
email::String
id::DbId = DbId()
username::String = ""
password::String = ""
name::String = ""
email::String = ""

### VALIDATION
validator::ModelValidator

### CALLBACKS
# before_save::Function
# after_save::Function
# on_save::Function
# on_find::Function
# after_find::Function

### SCOPES
# scopes::Dict{Symbol,Vector{SearchLight.SQLWhereEntity}}

### constructor
User(;
### FIELDS
id = DbId(),
username = "",
password = "",
name = "",
email = "",

### VALIDATION
validator = 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)
]),

### CALLBACKS
# before_save = (m::User) -> begin
# @info "Before save"
# end,
# after_save = (m::User) -> begin
# @info "After save"
# end,
# on_save = (m::User, field::Symbol, value::Any) -> begin
# @info "On save"
# end,
# on_find = (m::User, field::Symbol, value::Any) -> begin
# @info "On find"
# end,
# after_find = (m::User) -> begin
# @info "After find"
# end,

### SCOPES
# scopes = Dict{Symbol,Vector{SearchLight.SQLWhereEntity}}()

) = new("users", "id", Symbol[], ### INTERNALS
id, username, password, name, email, ### FIELDS
validator, ### VALIDATION
# before_save, after_save, on_save, on_find, after_find ### CALLBACKS
# scopes ### SCOPES
)
# 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

function hash_password(password::String)
Expand Down

2 comments on commit 64fe263

@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/22825

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.5.0 -m "<description of version>" 64fe26360ba9c11dd9746786783751cc0f9a87be
git push origin v0.5.0

Please sign in to comment.