Setting up forgotten password reset link (MERN stack) - node.js

I'm working on a project, where I have implemented an API for logging in and registering users. Everything works for me...except one thing: the forgot password feature. In that case, when I click the link that is sent to my email address, I get a blank screen and a console error about mime types. The error is: Refused to apply style from 'http://localhost:3000/passwordreset/index.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
What I should get instead is a React component with username, password, and confirm password fields. But it won't display when I click the link in the email.
Even worse...now the error itself disappeared (not sure what I did), and the component (PasswordReset.jsx) still won't render.
I've verified and reverified the routes, query params, and so on...any thoughts?

Nevermind! I mistakenly had a route with a query param, but missing a '/' character. So, I had:
<Route
exact
path="/passwordreset:resetToken"
component={PasswordResetScreen}
/>
instead of:
<Route
exact
path="/passwordreset/:resetToken"
component={PasswordResetScreen}
/>

Related

Express combining two directories and changing the path

So I'm making an app with nodejs, express, and angularjs. I was following a couple of tutorials and decided to integrate into my project.
I have a index.html and there there is a button to create a multi-step form using Angularjs and UI-route. Form link
Then I found a youtube playlist for MEAN Stack, server works fine. As everyone I routed /public also.
app.use(express.static(__dirname + '/public'));
The problem starts here,
Button in the index.html it supposly goes to /app/views/forms/main-form.html to create the ui-view.
<div class="btn">
<form action="/app/views/forms/main-form.html">
<input type="submit" value="Get Started" />
</form>
</div>
Before I integrated express into my project, the path was working fine. Somehow, I think something to do with Express, when I click I get the following 404 error.
Refused to apply style from 'http://localhost:8080/app/views/forms/assets/css/form.css'
because its MIME type ('text/html') is not a supported stylesheet MIME type, and
strict MIME checking is enabled.
My problem is not about being a MIME type. The original path to CSS is /assets/css/form.css, but somehow it takes the form-main.html path at the beginning which is /app/views/forms also.
It is the same with formController as well. The controller normally is in the path of /app/controllers/formCtrl.js but the error goes like /app/views/forms/app/controllers/formCtrl.js
I would like to know how it takes two directories and combines them and why?
Edit
After using the CDN of Angularjs instead of local lib, it can get the link directly. But combining two directories is still continue to happening.

OWASP ZAP against Netlify password protected site

I need to run OWASP ZAP against one of our sites running on Netlify, but it is password protected (see screenshot for what I mean). For those who don't know how it works, when you visit the site, Netlify returns a 401 with the response of the request being the form. The form takes a password (input name is password) and POSTs it to the same URL (so https://myapp.netlify.app/ returns 401 and then the form POSTs it to https://myapp.netlify.app). I've created the context that should work, but I don't think it likes the 401 being returned as the same URL as the POST.
I'm sure I'm just doing a really stupid thing, but here is the relevant snippet from the config:
<authentication>
<type>2</type>
<strategy>EACH_RESP</strategy>
<pollurl/>
<polldata/>
<pollheaders/>
<pollfreq>60</pollfreq>
<pollunits>REQUESTS</pollunits>
<form>
<loginurl>https://myapp.netlify.app</loginurl>
<loginbody>password={%password%}</loginbody>
<loginpageurl>https://myapp.netlify.app</loginpageurl>
</form>
</authentication>
I also tried this snippet, in case it required the username (the UI kept enforcing the use of username):
<authentication>
<type>2</type>
<strategy>EACH_RESP</strategy>
<pollurl/>
<polldata/>
<pollheaders/>
<pollfreq>60</pollfreq>
<pollunits>REQUESTS</pollunits>
<form>
<loginurl>https://myapp.netlify.app</loginurl>
<loginbody>username={%username%}&password={%password%}</loginbody>
<loginpageurl>https://myapp.netlify.app</loginpageurl>
</form>
</authentication>
School boy error. I had everything configured properly, but wasn't providing the user (I thought the forced user would be picked up).
Running zap-baseline.py -t https://myapp.netlify.app/ -r testreport.html -n /zap/wrk/myapp.context -U testuser works.

String was not recognized as a valid Boolean. in mvc5 show error in #using in razor

I am using mvc5 for application my local system application is working properly. but I upload publish file then server shows error show
Would be nice if anyone helps about it
Without seeing more code, it is hard to tell, but at a guess, you may want to look into your config file(s) and particularly the transformation side of this value in app settings.
<add key="ClientValidationEnabled" value="true" />
It may have an incorrect value which cannot be parsed, which is why the error is occurring down the stack after "get_clientvalidationenabled" is called.

Disable ClientSide Validation

in this posting:
How to disable Client-side Validation for an XPage?
Sven demonstrated setting the property to disable the client side validation.
<xp:this.properties>
<xp:parameter name="xsp.client.validation" value="false" />
</xp:this.properties>
I tried this in a test XPage and it works great, I then tried it in my application and I get an error when the Submit button is clicked that my Rich Text Field is undefined. I have a custom control that contains all the input and validation and it is called from the an ext Lib Application Layout Control. I have removed most everything I can from my App Layout but when I do a submit it does the correct validation but also gives the message:
---------------------------
xpWFSDemoInput
---------------------------
An error occurred while updating some of the page.
dijit.byId("view:_id1:_id2:_id3:_id4:callback1:_id145:callback1:_id148:inputRichText1") is undefined
---------------------------
OK
---------------------------
I place my input custom control inside a new Xpage, set the parameter on the Xpage and run it and it works fine, it sees the RichText and processes it correctly. So there would appear to be something in the App Layout that is causing problems.
I will try putting the Ext Lib Applayout into an XPage and see what happens.
Some further info -- I found the problem code which is some client side script that does a periodic time check. No idea why it hates the RTF though.
If you want to disable client-side validation for the application, you can do so in the Xsp Properties in the application. You can also do it in an xsp.properties file on the server. Check out XPages Portable Command Guide for more details on this and all xsp.properties settings

Custom errors not working with IISExpress

I have a asp.net mvc application and am trying to get custom errors working with IISExpress.
Works in Casini fine:
<customErrors mode="On" defaultRedirect="/error">
<error statusCode="404" redirect="/error/notfound"/>
</customErrors>
When I've deployed mvc sites to IIS (7.5) before, all I had to do get my custom errors working was to set:
<httpErrors errorMode="Detailed"/>
I've tried explicitly specifying the status codes within the httpErrors section but nothing works. Here's an example:
<httpErrors errorMode="Detailed" defaultResponseMode="Redirect">
<clear/>
<error statusCode="404" path="/error/notfound"/>
</httpErrors>
Any ideas?
Thanks
Ben
This was caused partly due to my misunderstanding of how custom errors are actually invoked and also the fact that (IMHO), the handling of errors in asp.net mvc is a bit messed up.
The first issue was that in a number of my action methods, I was checking for the existence of an object e.g. a blog post, and returning a HttpNotFoundResult if the blog post was null. I was under the assumption that this would then display the custom error page that I had set up for 404 errors.
However, this is not the case. Returning a HttpNotFoundResult simply sets the status code of the response to 404. The rest is then handled by IIS, displaying the IIS 404 error page or by your browser if it has it's own custom error page.
One solution here is to return a HttpException which will use your custom error pages since the request is be handled by asp.net.
I chose instead to create a new ActionResult that allowed me to specify a view along with a http status code. I preferred this to throwing exceptions.
The next issue was that by default a new MVC project has a greedy route defined. If you make a request to /foo/bar the default MvcHandler will look for a controller called Foo. When it can't find it, it will return 404.
I had removed the default route and had no greedy routes. This meant that urls not matching any of my routes would not be handled by asp.net and would just fall back to IIS.
The solution here was to create a wildcard route at the bottom of my routing configuration to match all other requests and forward them to a custom PageNotFound action, that sets the status code to 404 and displays my custom view.
Some things worth pointing out.
You will need to set httpErrors errorMode="Detailed" for your custom error pages to be displayed in IIS/IISExpress. The rest however can be left alone.
Setting the defaultRedirect path in the customErrors section has no effect on 500 errors. This is because the global HandleErrorAttribute handles all 500 errors and just looks for a view called "Error" to display. This means that if your custom error page is actually a controller action, it will not be invoked. The above is true even if you explicitly specify a 500 error page.
You should still keep the defaultRedirect path however, as it will be used for other status codes if they are not specified explicitly.
If you are using iisexpress you can just comment out the entire httpErrors section < !-- --> in the applicationhost.config and replace it with the following:
<httpErrors errorMode="Custom">
<error responseMode="Redirect" statusCode="404" path="../missing/index.php" />
</httpErrors>
path is the url path to your custom site specific page

Resources