Hello devs,
Setting the high-security login method was a tough task in SteemPro. Today I completed the authentication logic. The hurdle was to get the login username during the server-side rendering. I did some research and decided to implement the Next Auth with a custom credentials login.
Only the sign-in option is required. So I add to login to Next Auth only with the username. Encrypted Private was not added to the auth as it's sensitive information even if it is encrypted. So I decided to keep the encrypted private key to local storage and use the Next auth login session to get the username on the server-side rendering.
Server-side rendering is used in NextJs to set the metadata and also to improve the overall performance of the app. Today I also covered the error boundary and loading states.
here is the simple implementation of the Next Auth.
import NextAuth from "next-auth";
import CredentialsProvider from "next-auth/providers/credentials"
const handler = NextAuth({
session: {
strategy: 'jwt',
},
providers: [
CredentialsProvider({
name: 'SteemPro Authenticator',
credentials: {
username: {},
},
async authorize(credentials, req) {
if (credentials) {
return {
id: credentials.username,
name: credentials.username,
};
}
return null
}
})
],
});
export { handler as GET, handler as POST };
Download SteemPro Mobile
https://play.google.com/store/apps/details?id=com.steempro.mobileVisit here.
https://www.steempro.comSteemPro Discord
Official Discord Server
Cc: @blacks
Cc: @rme
Cc: @hungry-griffin
Cc: @steemchiller
Cc: @steemcurator01
Cc: @pennsif
Cc: @future.witness
Cc: @stephenkendal
Cc: @justyy
Cc: @upvu
Cc: @h4lab
VOTE @faisalamin as witness
Upvoted! Thank you for supporting witness @jswit.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit