on master help sign in
Merge pull request #105 from ilyakooo0/develop

Develop

commit1843aa085f329c615b04a7dea634d5167c7821ea authoriko <ilyakooo0@gmail.com> dateFri 10 May 2019, 21:27 (7 years ago) parent54a2ebf671c6c5
3 files changed+26−4
denis/email.html+19 denis/src/Server/Auth.hs+1−1 denis/src/Server/Auth/Mail.hs+6−3
denis/email.htmlnew file+19
@@ -0,0 +1,19 @@
1+<html>
2+
3+<body style="font-family: sans-serif;">
4+ <h1>
5+ <div align="center" style="margin-top: 20vh;">
6+ <a href="#" style="font-size: 34px; font-weight: bold; display: inline-block; padding: 7px 13px 7px 13px; margin-bottom: 89px; text-decoration: underline; font-family: sans-serif; color: #555;">
7+ Log in
8+ </a>
9+ <br />
10+ <div style="font-size: 55px; font-weight: bold; border-radius: 10px; background-color: #eee; display: inline-block; padding: 7px 13px 7px 13px; box-shadow: 0px 5px 21px #bbb; background-image: linear-gradient(#f9f9f9, #eee);">
11+ 21<div style="display: inline-block; width: 10px;"></div>55<div style="display: inline-block; width: 10px;"></div>43
12+ </div>
13+ </div>
14+ <div align="center" style="margin-top: 233px;">
15+ <a href="#" style="text-decoration: underline; font-family: sans-serif; color: #555;font-size: 13px;">Revoke access</a>
16+ </div>
17+</body>
18+
19+</html>
denis/src/Server/Auth.hs+1−1
@@ -71,7 +71,7 @@ type LoginDescription = Description "Try to log in with the given email\n\nRespo
7171
7272type LogoutDescription = Description "Log out with the given cookie"
7373
74−type VerifyDescription = Description "Verify token with the verification code from the user.\n\nReturns 400 if the token was not supplied.\n\nReturns 498 if the token was parsed but is invalid.\n\nRetusn 403 if the token/code compination is invalid."
74+type VerifyDescription = Description "Verify token with the verification code from the user.\n\nReturns 400 if the token was not supplied.\n\nReturns 498 if the token was parsed but is invalid.\n\nReturns 403 if the token/code compination is invalid."
7575
7676type RegisterDescription = Description "Register the user for a new account.\n\nReturns 409 if a user can not be created. (Most likely the email is already registered).\n\nSets the token if creation was successful.\n\nYou should prompt user for code and verify the token with `/verify`."
7777
denis/src/Server/Auth/Mail.hs+6−3
@@ -19,8 +19,9 @@ import Network.Mail.SMTP
1919import Server.App
2020import Server.Auth.Token
2121import Control.Monad.IO.Class
22−import Network.Mail.Mime (Mail)
22+import Network.Mail.Mime (Mail, Part)
2323import Data.Text (Text, pack)
24+import qualified Data.Text.Lazy as TL
2425import Data.Text.Lazy (fromStrict)
2526
2627sendTokenVerificationEmail :: TokenVerificationCode -> Text -> App ()
@@ -30,10 +31,12 @@ sendTokenVerificationEmail code email = do
3031 (Address (Just "HSE Social Network") "noreply@hse.ru")
3132 [Address Nothing email] [] []
3233 "HSE Social Network Verification Code"
33− [plainTextPart . fromStrict . pack . show $ code]
34+ [genMail . show $ code]
3435 sendMailWithConfig mailCfg mail
35− -- sendMailWithLogin' "smtp.sendgrid.net" 25 "apikey" "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" (simpleMail (Address (Just "HSE") "foo@hse.ru") [(Address (Just "YOU") "iikostyuchenko@edu.hse.ru")] [] [] "HI" [plainTextPart "HELLO\n\nsosi"])
3636
3737sendMailWithConfig :: (MonadIO m) => MailConfig -> Mail -> m ()
3838sendMailWithConfig (MailConfig host port user pass) =
3939 liftIO . sendMailWithLogin' host (fromIntegral port) user pass
40+
41+genMail :: String -> Part
42+genMail [a, b, c, d, e, f] = htmlPart $ "<html><body style=\"font-family: sans-serif;\"> <h1> <div align=\"center\" style=\"margin-top: 20vh;\"> <a href=\"#\" style=\"font-size: 34px; font-weight: bold; display: inline-block; padding: 7px 13px 7px 13px; margin-bottom: 89px; text-decoration: underline; font-family: sans-serif; color: #555;\"> Log in </a> <br/> <div style=\"font-size: 55px; font-weight: bold; border-radius: 10px; background-color: #eee; display: inline-block; padding: 7px 13px 7px 13px; box-shadow: 0px 5px 21px #bbb; background-image: linear-gradient(#f9f9f9, #eee);\">" <> TL.pack [a, b] <> "<div style=\"display: inline-block; width: 10px;\"></div>" <> TL.pack [c, d] <> "<div style=\"display: inline-block; width: 10px;\"></div>" <> TL.pack [e, f] <> "</div></div><div align=\"center\" style=\"margin-top: 233px;\"> <a href=\"#\" style=\"text-decoration: underline; font-family: sans-serif; color: #555;font-size: 13px;\">Revoke access</a> </div></body></html>"