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

Added 0 padding to code in email

commite5b7fee78f3ffab39d01d3ad0bda4f4262f113c4 authoriko <ilyakooo0@gmail.com> dateFri 10 May 2019, 21:36 (7 years ago) parent1843aa0a5f9f69
1 file changed+7−5
denis/src/Server/Auth/Mail.hs+7−5
denis/src/Server/Auth/Mail.hs+7−5
@@ -10,6 +10,7 @@
1010 UndecidableInstances,
1111 DeriveAnyClass,
1212 RecordWildCards #-}
13+{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
1314
1415module Server.Auth.Mail (
1516 sendTokenVerificationEmail
@@ -20,9 +21,8 @@ import Server.App
2021import Server.Auth.Token
2122import Control.Monad.IO.Class
2223import Network.Mail.Mime (Mail, Part)
23−import Data.Text (Text, pack)
24+import Data.Text (Text)
2425import qualified Data.Text.Lazy as TL
25−import Data.Text.Lazy (fromStrict)
2626
2727sendTokenVerificationEmail :: TokenVerificationCode -> Text -> App ()
2828sendTokenVerificationEmail code email = do
@@ -31,12 +31,14 @@ sendTokenVerificationEmail code email = do
3131 (Address (Just "HSE Social Network") "noreply@hse.ru")
3232 [Address Nothing email] [] []
3333 "HSE Social Network Verification Code"
34− [genMail . show $ code]
34+ [genMail code]
3535 sendMailWithConfig mailCfg mail
3636
3737sendMailWithConfig :: (MonadIO m) => MailConfig -> Mail -> m ()
3838sendMailWithConfig (MailConfig host port user pass) =
3939 liftIO . sendMailWithLogin' host (fromIntegral port) user pass
4040
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>"
41+genMail :: TokenVerificationCode -> Part
42+genMail code = 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>"
43+ where
44+ [a, b, c, d, e, f] = reverse . take 6 . (++ repeat '0') . reverse . show $ code