Change the resetpassword url host in meteor - meteor

I want to change the reset-password email template url
I want to change
localhost:3000/reset-password/dP8cuMPE220mEPA7l0uSRIq4
to
app.mysite.com/reset-password/dP8cuMPE220mEPA7l0uSRIq4
I've done this
Accounts.emailTemplates.resetPassword.text = function(user, url) {
url = url.replace('#/', '');
url = url.replace('localhost:3000', 'app.mysite.com');
return "Click this link to reset your password: " + url;
};
This works on my localenvironment but when in production it doesn't have localhost:3000
so the url will not change
I want to change the host, how to do this?

You need to set the ROOT_URL environment parameter. Meteor will use it to generate this link. So if you set ROOT_URL="http://app.myside.com/, then the generated url will be http://app.mysite.com/reset-password/blahBLAH.

Related

How to send Firebase paswordless login link?

I am trying to implement magic link login to my app. I enabled email login option through Firebase console and localhost is already under the authorized domains. I have the code snippet and the screenshot in the below.
I can see that some request is being done with 200 success code but I receive no email.The code does not throw any error and I have no idea what is wrong at this point. Can someone help?
export const sendMagicLink = (email: string, redirectUrl: string) => {
const auth = getAuth(getClientApp());
const actionCodeSettings = {
url: redirectUrl,
handleCodeInApp: true
};
return sendSignInLinkToEmail(auth, email, actionCodeSettings);};
const handleSubmit: svelte.JSX.EventHandler<SubmitEvent, HTMLFormElement> = async ({
currentTarget
}) => {
email = new FormData(currentTarget).get('email') as string;
const redirectUrl = `${window.location.origin}/auth/confirm`;
state = 'submitting';
try {
await sendMagicLink(email, redirectUrl);
setMagicEmail(email);
state = 'success';
} catch (error) {
if (error instanceof Error) {
state = error;
} else {
console.log(error);
state = new Error('something went wrong sending the magic link 😞');
}
}
};
Request body:
canHandleCodeInApp true
continueUrl "http://localhost:3000/auth/confirm"
email "someemail#gmail.com"
requestType "EMAIL_SIGNIN"
Intuitively a developer assumes that emails sent out by Firebase's internal email service will not be classified as spam, but this happens very often.
To solve this, one would need to:
Setup a custom domain for Authentication in Firebase Console
Go to Firebase Authentication
Go to Templates
Go to Email Address Verification
Click Edit
Click Customize domain and go through the whole process
Setup a proper SMTP server in Firebase Console
Go to Authentication
Go to Templates
Go to SMTP Settings and enter SMTP Settings. Use the same sender domain as has been used in Email Address Verification above.
Setting Action URL
Set your custom domain in the Hosting section, first, e.g.: example.com.
Then, in the Authorization Templates section, click Edit and adjust the Custom Action URL at the bottom of the page. Set it to the same domain used for Hosting, e.g.:
https://example.com/__/auth/action
This helps to decrease the spam ranking of the emails, as the outgoing email from domain A will now contain a link to domain A.
In contrast, an email from domain A carrying a link to domain B is more suspicious.

Karate - Authentication - cannot access url address under password

Using Karate, I have need to use basic authentication (to pass common authentication dialog window with username and password), and I have tried this: https://github.com/intuit/karate#http-basic-authentication-example).
I have created the file basic-auth.js
function fn(creds) {
var temp = creds.username + ':' + creds.password;
var Base64 = Java.type('java.util.Base64');
var encoded = Base64.getEncoder().encodeToString(temp.bytes);
return 'Basic ' + encoded;
}
I have added the call to the test feature file I run (added to Scenario section):
header Authorization = call read('basic-auth.js') { username: 'realusernamestring', password: 'realpasswordstring' }
Then I have placed the url I want to access right after:
driver urlUnderPassword
But it did not work, I still cannot access the page. I think there is something missing, something what needs to be done. Could you help me what the problem might be?
Thank you.
What you are referring to is for API tests not UI tests.
If you need the browser / driver to do basic auth it should be easy, just put it in the URL: https://intellipaat.com/community/10343/http-basic-authentication-url-with-in-password
So I am guessing something like this will work:
* driver 'http://' + username + ':' + password + '#' + urlUnderPassword

Libgit2sharp:how to use "git pull“

using (var repo = new Repository("path/to/your/repo"))
{
LibGit2Sharp.PullOptions options = new LibGit2Sharp.PullOptions();
options.FetchOptions = new FetchOptions();
options.FetchOptions.CredentialsProvider = new CredentialsHandler(
(url, usernameFromUrl, types) =>
new UsernamePasswordCredentials()
{
Username = USERNAME,
Password = PASSWORD
});
repo.Network.Pull(new LibGit2Sharp.Signature(USERNAME, EMAIL, new DateTimeOffset(DateTime.Now)), options)
}
i do not konw how to set arguments,when i use it,one error will show-----Unsupported URL protocol.could you tell me how to set arguments?
It depends on the url you are using.
For instance, issue 649 clearly states:
git.git supports relative URLs in remote configurations and resolves them relative to the working directory.
libgit2 currently fails with "Unsupported URL protocol".
It expects paths to be absolute.
So if your url is actually a local path, make sure it is an absolute path (and not a relative one).
As commented by 崔重阳, using an https instea of an sssh url is supported.

Which file should I use Accounts.sendVerificationEmail?

I implemented login functionality using Meteor. I want to send a verification email whenever a new user is created. According to the documentation, I should use:
Accounts.sendVerificationEmail(userId, [email])
on the server folder.
However, I feel that it is lacking in implementation details. What file should I create to use this method? Does it have to be in a specific folder?
I made file in ../server/config.coffee:
Accounts.config
sendVerificationEmail: true
forbidClientAccountCreation: false
Accounts.emailTemplates.siteName = "blabla.com"
Accounts.emailTemplates.from = "blabla.com site Admin <admin#blabla.com>"
Accounts.emailTemplates.verifyEmail.subject = (user) ->
"Confirm registration on " + Accounts.emailTemplates.siteName;
Accounts.emailTemplates.verifyEmail.text = (user, url) ->
"To confirm your registration, please, click this link " + url
Of course, you have to setup process.env.MAIL_URL too.

force https in a response.redirect

I want to redirect to a page that and force https:
e.g
Response.Redirect("~/Login.aspx");
I want to redirect to
https://myserver/Login.aspx
how can i force https?
Thanks Silky for starting me off.
I've ended up with
var url = String.Format("https://{0}{1}",
Request.ServerVariables["HTTP_HOST"] ,
ResolveUrl("~/Login.aspx"));
Response.Redirect(url);
I like to call this method from Page_Load in any page where I want to force https. Specifically, from any page where the user may enter a password, such as login, registration, and password reset pages.
protected void ForceHTTPS()
{
string serverName = Request.ServerVariables["SERVER_NAME"];
string pagePath = Page.AppRelativeVirtualPath.Replace("~", "");
string queryString = Request.Url.Query;
if (serverName != "localhost" && !Request.IsSecureConnection)
{
Response.Redirect("https://" + SECURE_DOMAIN + pagePath + queryString);
}
}
The reason I use a pre-defined constant for SECURE_DOMAIN rather than just reading it out of the Request.ServerVariables["SERVER_NAME"] is that our SSL certificate only works if there is a "www." on the beginning of the domain name, so I want to make sure to force that domain name too in case the user has browsed to the site using the domain name without the www., or potentially used some other domain name alias.
And I do not do the redirect if the server name is "localhost" so that the code also works in my development environment when run from Visual Studio.

Resources