Golang HTTP User Authentication Yabi Series 6 | Golang Web Development | WebAssembly Auth System

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] okay guys welcome back to the channel this is tutorial series number 26 here in harlequin's code okay we are still in this uh yabby series guys this is our sub uh topic here in our web development series in golang okay so we're still in the yabby series number six okay so we will be creating and then we will be continuing our um user's authentication guys uh we are about to create what they call this the email automatic email response to our once the user has been registered successfully or we enable this is active is true or false means it falls that means we need to uh send and uh we need to send an automatic email address upon uh the success of the successful users registrations okay there is one more thing guys i would like to share it with you that will um if you want to uh mention your name here or i will make a shout out just leave a comment below so i can read your names and then i can read your names and then you will be uh displaying our thing guys just comment uh just comment below guys and then i will just mention that you want to shout out your name here so that i can read names uh after uh uh after the tutorial series after our tutorial uh video so i would like to read names at the end at the end part so this would be um would like i would like to of course honor our viewers here as well so our uh here in varlikan's code so okay guys just leave a comment below there just uh mention uh whatever it is you want to shout out here in our uh video okay um we will continue and then we will create the user's registration uh we already successfully created that we inserted in our database and then after that we block these um duplicate entries for the username and the uh email address and now we want to confirm that the users really have this uh account i mean this user's email address is valid or not so if they um receive an email notification there saying that this your account must register or something then just click this button and then they will be confirmed their users registration in your site so this would be the thing and just dive into this tutorial guys guys welcome back to the channel okay uh we will continue on uh right now guys we need to prepare our uh smtp we need to create a new file here called the smtp under this yabi package here guys so we need to prepare create a new file uh shall we say smtp we call it smtp.go okay we just named this like this guy so still we're using this yabi package of course and then we would like to create this kind of a struck we need to prepare our structures guys we call it the email probably config okay the struct uh this would be our our data collection guys uh when we send out the email because right now we need to use uh sun grid or the classic smdp okay uh but in this tutorial first we will deal with the same grid since i have the same grid account there the api key that one is just a free one guys so you can just uh get also this sendgrid api key that you can send about a 100 per day so 100 emails per day so you can it's a decent amount for our testing guys but of course you can always upgrade guys uh okay so we will continue we will continue on okay this one would be our yabby email configuration guys okay configurations okay then we can uh we will have something like this common email collection guys um from two cc then then bcc and we will just uh these are all the strings here and then we can also have some alias guys i mean this one alias is very important as well um but this one is optional and that's not really so important okay this one is for the email address guys something like you have some alias there then you can do this okay so later part i will just expand all this information guys later we will just put some comment there so we will need to collect the subject okay so okay i just want to make it separate guys the string i don't want to group together uh on only those uh the common one like the from 2 cc bcc that but this subject is and i want to emphasize all these things okay so just hold on varwa string then user name okay site uh support we need this also uh we just fill in all this information guys so these are the very common for our email confirmation guys i mean for our authentication system email confirmation url this one is for our uh link later on guys when we broadcast or when we automatically send an email to the user when there is a user's registration there and then they will receive an email and then after that they will click some registration button there okay so continue and then we have some customized header template as well template okay this one later i will just explain guys customize body template okay and then customize footer template this one is all yours all your customized configuration guys when you have some customized header template the body and then the footer this email is um is an htm html format guys so nowadays we're all using the html format guys they're all modern email format to send from the user so okay so we just continue on template then we just string okay okay guys uh we will continue on uh we will be using sand grid guys so in our previous videos and discussions uh we are all using this uh my own what they call helper guys for our thing uh to send an email so either the send grid or what they call this uh classic smtp so uh we will be having this soulad package here you can just head over to um if you want guys okay so if you want you can just uh use this these are all you can freely use guys okay so you just want to go get this one and then we can install into our thing so we will be using this as easier for us to use guys because we already done this that's a good thing if we publish some package to the get up there then we can just freely use these guys and then use in our uh golang projects okay so now i mean installing this zulet package right now we need to [Music] execute this i need to clear this go mode vendor guys and then we can just use this we will just want to initialize this um sgc again all these guys so so let this sgc just so okay should be blank was because we don't have any we just want to initialize uh this um this uh global variable guys for the solar package okay this one is for the sun grade guys send grid right now we are using design grid to send grid uh smtp so that we can send and receive i mean send an automatic email to our uh users registration there guys so okay guys to capture our time guys i i pasted all these things guys so it's easy for us and then we captured our time this one is uh this one we have already done in our previous discussion so no need for us to retype again all these things so i just i want to have a quick overview here this is our setup for the sendgrid api so we were just using this version 3 for the for this api sendgrid so if you don't have the sendgrid api you can just head over to this uh site uh called the sendgrid.com and then you can sign up freely there and then you can get your own api key so that you can follow along with this discussion guys you can follow in this discussion here and then so okay so we will continue on guys and this one i already done this in a previous discussion so also i pre set up all these things guys for our for example this is our example email all this uh description guys as you know when you use this property of this email config then you can have all these uh nicely what they call this nice information here so that it when you the intellisense then it will pop up this one guys so okay and then this one default template we will have this uh defined here as a new user email these are all the default template that our package will be using guys like a new user email confirmation and then the password they said so uh this will be our uh default one but if the user key in or you guys out there keynote this uh customizer header folder of course we have our own html design for our email content so we will have these things there all these configurations so we are all in place guys so probably we will add on or remove few of these this one is a very raw first row settings and configurations and properties of our email so in the long run we will be adding or removing few of things here we don't know yet so we'll just go along and then we proceed and then this one already set up guys all these things hey so you can just follow along to catch our time and then of course these uh these are all the settings uh now we would like to create um another file called um this one we will call it um format something like email format that go okay and then uh we will have this uh package uh you know you know package obviously i guess we are all talking with email address that's right okay so uh we will create our uh what they call this default email address guys so in this case we will have our own uh constant email format new user okay this one is our default one guys okay this is for the yabi uh authentication guys um what i call html format a new user email confirmation should be like this okay so again we will um later i will just fill up all that one guys this one again is for constant we need this email format uh password reset okay quite long guys must be uh what do you call this uh unique variable there okay don't reuse a common variable guys this one is a very specific okay very specific email i mean the variable i suggest and i recommend for you to create that one guys some people always create similar uh for other language guys because they they allow that one so for us here we don't we don't do that especially here in golang okay so we will set up okay to continue again guys i will catch our time again uh these are all the html format here guys okay so these are all uh predefined uh you can have your own guys later i will share this code in our github there so so that you guys can grab all this html format this is for when we send an email guys to our email recipient when someone registers so they will receive this email format now we will have this yeahb html header here this is our default um this is our default header here and then these are all the settings guys so it's quite long one you can later you can just grab this uh when i publish this on our github so but in the meantime you can have your own as well okay while i'm not uploading it yet but normally i will upload by batch guys so it may take some time okay then this is our yabi html folder here so this is for our footer of course uh this one is the the whole html guys we just want to split it into footer header and then the body one because we at least we can reuse uh normally guys normally is uh when we have the html email there we can reuse all those things uh we don't want to repeat ourselves like like the header and the footer there uh when we have a similar uh html format when every time when we have an automated email email there then you can split over it guys and the only thing split it with the header footer section and then of course the body of the html so at the moment i created this a new function this new function is for specific for the new user's registration later we will create another one for the password reset all these things okay at the moment we are focusing on uh in our users registration so i created a new function under this email underscore format that go still under the yabi uh package here okay later you will see these guys when we [Music] when we sign up with the registration there and then you will receive an email or something like this but right now we are still working on locally guys so we never publish it in our maharlikansko.com there in our production site but uh right now we are still working on the development but we can still uh receive email uh by uh by using this ascend grid guy so even though you're working locally on your development pc there and then you can just after this you can sign up you can play around and then with our users registration okay so [Music] continue on and then this is our table guys we just um we just later we will just enhance this one guys uh this one probably this would be our uh variable here uh we will enhance this in our next discussion guys but right now our focus is to um to send an email when they it will trigger an email uh when there is a user's registration okay so this this is our body of the email guys okay html body like a hello side thank you for signing up and then there is some rocket there and then the confirmation button but uh right now we don't create the confirmation yet uh okay this is the end of the story here for the email format okay uh just relax a bit guys uh take your coffee first don't go out outside with without a mask guys huh peace okay you can learn a lot here in marlinkans just a sideways guys okay um okay we have done this email format guys now we will go back to our user's go um probably this is our yeah this is okay when we insert before we insert to our database here uh before we insert then uh we will trigger first if uh we have this uh email thing guys so okay uh the best thing we can insert this is amelia this one is a better place it's a better place guys okay okay so we will put here guys our thing so probably this one is uh if u dot that's not coming hold on guys okay and just maybe hang forward okay guys uh i just reloaded our thing our uh what they call this editor i guess our favorite editor so if this one we will check guys now is activist uh if it is false okay if this statement is false here uh i mean the because we need to send out um from our here in our wasab here so we set it to true that means uh must set to false guys so we need to um so that this one will okay i will just turn to false so that well we need to send an email confirmation guys now we are working closely with this email confirmation now uh in our previous discussion we um we are directly inserting into it into the database first but the status is uh it's not active yet the user is not active so now we change over to the original one which is that is active is false by default it should not be true guys okay this one is a this one is a public users registration guys okay uh if you have your internal administrator like this one is uh because we can configure it like uh internally you can your own administrator your own local administrator to your system or whatever you're using you're building a framework or size or something you have your own internal administrator that no need the common users and they don't like the public users this one is a public users now so we need to turn this off first so when we insert a new user's registration this one is by default should be false okay please remember that one guys maybe you're scratching your head like again this one is a funny mistake i guess and just be careful okay um this one is me should false now okay so we can send over the email confirmation by default it's not active the user's account during the when they register to our site okay so now if it is false then we will send an email here guys okay uh we will check order if again we will check here if the email address uh we will check here guys so if check if again the normal validation guys email address is empty okay so we don't allow if lan strings dub our favorite one always check this one guys okay because um this one is can save you can save us guys okay and this one e from uh right now we don't have the e yet so we need to pass on to our uh email confirmation guys um in our thing is we need to have e now here e as our email config okay so we need to pass on and add on all this configuration this configuration is found in our smtp here so this one guys so now we are collecting all this information okay so we will collect this information because we have already have this uh struct there so before we call this create user so we need to pass on all this information now but at the moment we don't have yet okay so now it's here so we will just pass one guys and then return zero here then errors dot new and then from email address is required of course yes we need to require all these things and then we just copy over all these things okay and this is for the email address this is for the from and then two email address guys so we need this uh two email address is required this one also must be two okay this one is two okay we have done here and then we need to check our subject guys and now we are forming our subject and then the content all these things to prepare our email html email to be broadcasted to the user's email address guys automatically so just hang on for a while guys check it from check if subject okay this one is the subject here is empty okay so so this one would be email subject so we will just put a local variable here guys okay activate your new just want to concatenate guys yeah this one is your own uh but uh later we will enhance guys this one for sure this one is too specific to to this uh [Music] tutorial later we will pass on this subject formation you can okay okay yeah we just want to later we will not guess okay okay no worries okay and this one we just want to see the beautiful email there when we receive upon the user's registration guys okay this is our goal for this tutorial today okay then we pass on this email subject is a edit subject okay so we'll just use that later on okay okay guys uh i have to capture the time again i speed up a bit guys so so you guys don't get bored okay um i explain a bit guys a little bit only promise okay uh this one is the user's authentication guys now is uh uh we are having this subject here this is for the subject and then this is for our uh default uh yabi html header so this is our html header here so if not now if it is a blank here the customize header then we will use um if this one is uh if you guys are there key in this customized header template then we will use of course the yami will the yabi authentication system will be using this of course your own customized header the same thing with the body here so the body if you have the body html then you can use it but the default is uh the yeah be there okay so uh here again this is the thing for our footer and then same thing with the footer then this is for the specific we have done this as well guys in our previous uh long back ago we have done all these things for the sulad package to send an email using the sun grid okay so you can we can have all these things uh all these default settings as we just copy over all these things uh we have done all this our own package there so you can just really use it and then of course uh this is our existing one so prior to stand uh prior to insert an email i mean the the thing here so we prioritize to send an email guys uh this one is very fast only so after this then we will insert into the table okay so we have done all these things need uh to send and to send an email address to send an email guys so this is our thing here the subject or something like this guys uh actually the subject that we can no longer use that okay uh hold on for a while guys uh the subject where is that subject email this one is for the default one guys so uh okay so this is the default here activate your new account this is for the default okay hold on guys activate your new account activate your new account okay this one is for the default setting guys so we can just remove that because we already supplied the subject here this is your own customized subject guys okay if you don't fill up this one then we will use that this one our default here activate your your new account okay we want to build the more as much as possible as a customizable package guys okay uh to cater every needs but not all but it's a decent enough already okay then we need this uh to include guys now because our create user we added this um uh yabi email config so we need to put it here and then okay we added a extra thing now okay this one also so later part we will have our redirect as well guys but at the moment we don't have yet so we just want to when the users registration then we can redirect to a certain page but uh let's say we just want to we don't want to add at the moment guys okay later of course we will do that we just want to receive an email guys okay uh we now should be okay this one is my other site so this one is built by python and jungle okay um this one is for the bcc we just want to test only guys well for the bcc and cc you can also have this but here no point to cc yes because this one or if you want the bcc that you oh you can this one is all optional as well so uh we don't know maybe we can just remove over guys okay the important one is the two only because this one is the user's email and then this is our default email address from our config like the from guys okay so we continue on i think this one is good enough now guys so we can send go run main.go need to be in your root uh whatever the the wasam um file there i mean the for what i made that go for the wasam guys you need to build uh in that directory okay and just a quick reminder only uh now we can build go build uh with uh oh argument and then we need the we need this uh directory guys we need to throw directly to our assets js and then the out there okay um okay then we name it as uh dot wasa then main.go as our source file to build to build okay now is no error so should be fine so now we don't need this uh so lut here so we just want to refresh oh i also changed to register button guys in our previous discussion still login now i remember okay right now i also clear everything here guys so we should have a clear input here okay so from our yabby table so at the moment we can just say admin and then use my email one of my personal email address and then we just say uh this one this password also we will enhance guys in our next video probably guys okay uh i mean the land and then there is a special character or something like that yes so let's see if there is an error register oops i already clicked let's say okay registered so i should receive an email address oh no it's i think i have here pointing no yes uh now i receive guys okay support team oh very nice activate your harlequins code account so there is a rocket there okay uh there's a nice this one is a dark theme guys okay uh i mean it's not nice auto guys okay uh this one is a mobile friendly html email as well uh we can try to make it um what is the setting here i forgot here i think here guys so we need to change the thing personalize okay uh maybe light mode so that you can see it clearly as well so the light mode should be uh this one gets the welcome to my elegance code so uh automatically it's sent to this email because during the registration process i key in this email address so so for our testing guys so now is there is a confirmed registration here as well so by default the user is um the user is uh inactive now so we want to see this field as well here so it's active is zero zero means it's false guys okay so now is uh we can successfully uh create the auto email notification guys upon registration and then this one of course uh in our next video guys we will create a certain token there then we can confirm and then there is an expiration of that token so probably the expiration should be normally the default is 30 minutes but we will play around and create a page there something other than that when the user click this confirm registration so i think this is enough at the moment guys so uh we will be having this email confirmation now is a totally working one then the default also is a zero so means uh in our next video we will probably when we click this then it will confirm to the user guess and then of course we will validate as well like if this token we will encrypt that token guys no worries this one will there is some embedded payload there as well so when we when the user click this confirm and then it will go to the go to our pages there our page just to confirm guys there's another racket that's launching already okay so probably this is our um should be end here at the moment and then after that uh in our next video guys and because i don't want to quite not drag too long okay so we will uh in our next video guys we will enhance our wasab here we will redirect as well to a certain page first like uh email confirmation something like uh we will redirect instead of staying in this page when the user click the register we will redirect to another page as well uh like saying like please check your email something like that guys so please check your email confirmation so that the user will know okay we'll not stay in this page after clicking the registration so probably stay tuned for that guys in our next video okay guys thank you so much for watching my video here and then i hope you enjoy our tutorial here in martin's code and um i hope you also learn a lot here in malacanang school guys so i i am happy that i am able to help others also again guys if you want to to to make it uh i would like you to honor here in maharlikan's code by displaying your name or mentioning your name um please comment down below so that i can like saying that you want to you want to mention your name here then i will personally mention your name so that i can honor you in our marlinkins code here so i hope you enjoy guys and uh please please take care of yourself um please wear masks okay uh math is very important guys okay uh in singapore it's all required here so we do one also in philippines philippines is more uh secured you will have some face shield here then then there is a mass inside okay please take care of yourself um also especially in this challenging times okay and then happy happy new year guys to all of you out there um in a few hours from now we will be celebrating the new years for the new year 2021 and i hope uh this pandemic will be over but again the trend is again the trend is uh the last year is uh december and january something that it started really but after that now again it started with the second okay um it's just a sideways guys and just don't be so serious okay so we will uh see you in my next video guys we will see you in my next video and then just comment down below if you want to be honored here in my hands code by mentioning your name or your project name or or whatsoever you want to mention guys so thank you so much for watching my video please consider subscribing to my channel guys martin's coach and that uh to order my works here in marlin school thank you so much for watching and may god bless us all thank you and bye bye [Music]
Info
Channel: Maharlikans Code
Views: 212
Rating: undefined out of 5
Keywords: go, golang web development series 26, golang web development course, web development with go, golang tutorial, learn to create web applications using golang, building scalable web apps in golang, golang good for web development, golang http user authentication, golang http authentication, golang user registration, golang authentication microservice, golang session authentication, golang webassembly, golang mysql, golang mysql tutorial, golang sql, golang sendgrid, smtp go
Id: yRQkCn5V6G0
Channel Id: undefined
Length: 40min 16sec (2416 seconds)
Published: Thu Dec 31 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.