Interim update

This commit is contained in:
a-ill
2023-07-30 13:04:15 +03:00
parent 9051fa90f3
commit 7c9bb1e830
111 changed files with 25589 additions and 170 deletions

27
Server/lib/Cookies.jl Normal file
View File

@@ -0,0 +1,27 @@
module Cookies
using HTTP, Dates, Genie
export set_cookies, set_remember, remove_remember
function set_cookies(params)
request = params[:REQUEST]
response = params[:RESPONSE]
if !occursin("__genierememberme",string(request))
headers = Genie.Responses.getheaders(response)
headers["Set-Cookie"] = replace(headers["Set-Cookie"],"Max-Age=2592000;" => "")
Genie.Responses.setheaders!(response,headers)
end
end
#=
function set_remember(params)
#cookie_remember = HTTP.Cookies.Cookie("__genieremember", params[:SESSION].id, path="/", expires=now() + Dates.Month(1), httponly=true,samesite=HTTP.Cookies.SameSiteLaxMode)
#HTTP.Cookies.addcookie!(params[:RESPONSE],cookie_remember)
end
function remove_remember(params)
#cookie_remember = HTTP.Cookies.Cookie("__genieremember", params[:SESSION].#id, path="/", httponly=true,samesite=HTTP.Cookies.SameSiteLaxMode)
#HTTP.Cookies.addcookie!(params[:RESPONSE],cookie_remember)
end
=#
end

View File

@@ -0,0 +1,53 @@
module EmailSupport
using Genie, Genie.Requests, Genie.Renderer.Json
using SMTPClient, JSON3, Random
export send_email
#--------------------------------------------------------------------
function send_email(receiver,subject,message)
url = "smtps://mail.privateemail.com:465"
rcpt = ["<"*receiver*">","<info@chrn.health>"]
from = "<no-reply@chrn.health>"
# Message body as RFC5322 within an IO
to = [receiver]
from = "no-reply@chrn.health"
replyto = "Chiron <info@chrn.health>"
body = get_body(to, from, subject, message; replyto)
resp = send(url, rcpt, from, body, opt)
return resp
end
# Load credentails
function load_credentials_inner(path)
credentials_text = open(joinpath(path,"credentials.json")) do f
read(f, String)
end
credentials_json = JSON3.read(credentials_text)
opt.username = credentials_json[:username]
opt.passwd = credentials_json[:password]
return
end
function load_credentials(path)
load_credentials_inner(path)
end
function load_credentials()
path = @__DIR__
load_credentials_inner(path)
end
opt = SendOptions(
isSSL = true,
username = "",
passwd = ""
)
#--------------------------------------------------------------------
load_credentials()
end

View File

@@ -0,0 +1,4 @@
{
"username": "info@chrn.health",
"password": "Ur4tdgishg"
}