<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: ForgetPasses</title>
    <description>The latest articles on Forem by ForgetPasses (@forgetpasses).</description>
    <link>https://forem.com/forgetpasses</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1013954%2F7ceff8aa-7b37-450f-99d8-1ee69e9bd764.png</url>
      <title>Forem: ForgetPasses</title>
      <link>https://forem.com/forgetpasses</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/forgetpasses"/>
    <language>en</language>
    <item>
      <title>Mastering Java: A Comprehensive Java Cheat Sheet with Code Snippets in 2023</title>
      <dc:creator>ForgetPasses</dc:creator>
      <pubDate>Sun, 05 Mar 2023 19:24:58 +0000</pubDate>
      <link>https://forem.com/forgetpasses/mastering-java-a-comprehensive-java-cheat-sheet-with-code-snippets-in-2023-3oak</link>
      <guid>https://forem.com/forgetpasses/mastering-java-a-comprehensive-java-cheat-sheet-with-code-snippets-in-2023-3oak</guid>
      <description>&lt;h2&gt;
  
  
  Java Cheat Sheet 2023
&lt;/h2&gt;

&lt;p&gt;Java is a versatile and widely-used programming language, known for its simplicity and robustness. Whether you are just starting out in Java or you are an experienced developer, having a comprehensive cheat sheet at your disposal can make a big difference. In this blog post, we’ll provide you with a full Java cheat sheet, organized by headers, that will help you understand the language and write code more efficiently. Additionally, we will also include code snippets to provide examples for each concept.&lt;/p&gt;

&lt;h2&gt;
  
  
  Data Types
&lt;/h2&gt;

&lt;p&gt;Java supports several data types, including primitive and reference types. Here are some of the most commonly used data types in Java:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;byte: 8-bit signed integer&lt;/li&gt;
&lt;li&gt;short: 16-bit signed integer&lt;/li&gt;
&lt;li&gt;int: 32-bit signed integer&lt;/li&gt;
&lt;li&gt;long: 64-bit signed integer&lt;/li&gt;
&lt;li&gt;float: 32-bit floating-point number&lt;/li&gt;
&lt;li&gt;double: 64-bit floating-point number&lt;/li&gt;
&lt;li&gt;char: 16-bit Unicode character&lt;/li&gt;
&lt;li&gt;boolean: true/false value&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is an example of how to declare and initialize each of these data types:&lt;br&gt;
&lt;code&gt;byte a = 127;&lt;br&gt;
short b = 32767;&lt;br&gt;
int c = 2147483647;&lt;br&gt;
long d = 9223372036854775807L;&lt;br&gt;
float e = 3.1415f;&lt;br&gt;
double f = 3.141592653589793;&lt;br&gt;
char g = 'A';&lt;br&gt;
boolean h = true;&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Strings
&lt;/h2&gt;

&lt;p&gt;Strings are a fundamental data type in Java that represent a sequence of characters.&lt;/p&gt;

&lt;p&gt;They are declared using the String keyword, and can be initialized using a string literal or by calling the String() constructor. Strings are immutable in Java.Once String object is created its data or state can’t be changed but a new String object is created. However, you can create new strings by concatenating existing strings using the + operator or the concat() method. Here is an example of how to create and use a string in Java:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// creating a string using a string literal
String message = "Hello, world!";

//Print the String
System.out.println(message);
// accessing the length of the string
System.out.println(message.length()); // prints 13

// accessing a character of the string using its index
System.out.println(message.charAt(1)); // prints 'e'

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code creates a string named message using a string literal, and demonstrates how to access its length and individual characters using the length() and charAt() methods.&lt;/p&gt;

&lt;p&gt;Strings are a powerful and versatile data type in Java, and are used extensively in many Java programs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Operators
&lt;/h2&gt;

&lt;p&gt;Java provides several operators that can be used to manipulate values, including arithmetic, assignment, comparison, and logical operators. Here are some examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Arithmetic: +, -, *, /, %&lt;/li&gt;
&lt;li&gt;Assignment: =, +=, -=, *=, /=, %=&lt;/li&gt;
&lt;li&gt;Comparison: ==, !=, &amp;lt;, &amp;gt;, &amp;lt;=, &amp;gt;=&lt;/li&gt;
&lt;li&gt;Logical: &amp;amp;&amp;amp;, ||, !
Here is an example of how to use some of these operators:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int x = 10;
int y = 3;

int z = x + y; // 13
z = x - y; // 7
z = x * y; // 30
z = x / y; // 3
z = x % y; // 1

x += y; // x is now 13
x -= y; // x is now 10 again
x *= y; // x is now 30
x /= y; // x is now 10
x %= y; // x is now 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Arrays
&lt;/h2&gt;

&lt;p&gt;Arrays are a fundamental data structure in Java that allow you to store multiple values of the same type in a single variable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1 Dimensional:&lt;/strong&gt;&lt;br&gt;
An array is declared by specifying the data type of its elements, followed by its name and size in square brackets. You can then assign values to the elements of the array using their index, which starts at 0. Here is an example of how to create and use an array in Java:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// creating an array of integers
int[] numbers = {1, 2, 3, 4, 5};

// accessing the elements of the array using their index
System.out.println(numbers[0]); // prints 1
System.out.println(numbers[2]); // prints 3

// changing the value of an element of the array
numbers[4] = 6;
System.out.println(numbers[4]); // prints 6

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code creates an array of integers named numbers with a size of 5, and initializes its elements with the values 1, 2, 3, 4, and 5.&lt;/p&gt;

&lt;p&gt;The elements of the array are accessed using their index, which starts at 0, and can be changed by assigning a new value to them. Arrays are useful when you want to store a collection of values of the same type in a single variable, and allow for efficient and easy access to their elements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2 Dimensional&lt;/strong&gt;&lt;br&gt;
In addition to 1-dimensional arrays, Java also supports 2-dimensional arrays, which are essentially arrays of arrays.&lt;/p&gt;

&lt;p&gt;Here is an example of how to create and use a 2-dimensional array in Java:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// creating a 2-dimensional array of integers
int[][] matrix = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};

// accessing the elements of the 2-dimensional array using their indexes
System.out.println(matrix[0][0]); // prints 1
System.out.println(matrix[1][2]); // prints 6

// changing the value of an element of the 2-dimensional array
matrix[2][1] = 10;
System.out.println(matrix[2][1]); // prints 10

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code creates a 2-dimensional array of integers named matrix with 3 rows and 3 columns, and initializes its elements with the values 1, 2, 3, 4, 5, 6, 7, 8, and 9. The elements of the array are accessed using their row and column indexes, which start at 0, and can be changed by assigning a new value to them. 2-dimensional arrays are useful when you want to store and manipulate data in a matrix-like format, and allow for efficient and easy access to their elements.&lt;/p&gt;

&lt;p&gt;If you have trouble understanding a 2D Array, here is a visualization of it:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OTlARXS0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oimxq3bo9da831whj4mc.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OTlARXS0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oimxq3bo9da831whj4mc.jpg" alt="Image description" width="512" height="182"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Control Structures&lt;br&gt;
*&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Java provides several control structures that allow you to manipulate the flow of your code. Here are some of the most commonly used control structures:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;if/else statements: used to conditionally execute code based on a Boolean expression&lt;/li&gt;
&lt;li&gt;for loops: used to iterate over a collection of items&lt;/li&gt;
&lt;li&gt;while loops: used to repeatedly execute code as long as a Boolean expression is true&lt;/li&gt;
&lt;li&gt;switch statements: used to execute different code blocks based on the value of a variable&lt;/li&gt;
&lt;li&gt;break and continue statements: used to modify the flow of loops and switch statements&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is an example of how to use some of these control structures:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (x &amp;gt; 5) {
   System.out.println("x is greater than 5");
} else {
   System.out.println("x is less than or equal to 5");
}

for (int i = 0; i &amp;lt; 10; i++) {
   System.out.println(i);
}

int i = 0;
while (i &amp;lt; 10) {
   System.out.println(i);
   i++;
}

int day = 3;
switch (day) {
   case 1:
      System.out.println("Monday");
      break;
   case 2:
      System.out.println("Tuesday");
      break;
   case 3:
      System.out.println("Wednesday");
      break;
  case 4:
      System.out.println("Thursday");
      break;
  case 5:
      System.out.println("Friday");
      break;
  case 6:
      System.out.println("Saturday");
      break;
  case 7:
      System.out.println("Sunday");
      break;
  default:
      System.out.println("Invalid day");
      break;
  }

for (int i = 0; i &amp;lt; 10; i++) {
    if (i == 5) {
        continue; // skip to the next iteration
    }
    if (i == 8) {
        break; // exit the loop
    }
    System.out.println(i);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Methods
&lt;/h2&gt;

&lt;p&gt;Java methods are blocks of code that perform specific tasks and can be called by an object of a class.&lt;/p&gt;

&lt;p&gt;They can accept parameters and return values, allowing for flexibility in their use. Methods can also be overloaded, meaning that multiple methods with the same name can exist in a single class as long as their parameter types or number of parameters differ.&lt;/p&gt;

&lt;p&gt;Here are two examples of how to create methods in Java, one with parameters and one without:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 1: Method with Parameters&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public static void greet(String name) {
   System.out.println("Hello, " + name + "!");
}

// calling the greet() method with a parameter
greet("Alice");

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code creates a method named greet() that accepts a String parameter named name and prints “Hello, [name]!” to the console. The method is then called with the parameter “Alice” using its name and parentheses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 2: Method without Parameters&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public static void greet() {
   System.out.println("Hello, world!");
}

// calling the greet() method
greet();

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code creates a method named greet() that doesn’t accept any parameters and simply prints “Hello, world!” to the console. The method is then called using its name and parentheses. Methods without parameters are useful when you want to execute a block of code that doesn’t require any additional input, while methods with parameters allow you to customize the behavior of your code by accepting input from the caller.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 3: Return a value&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public static int add(int a, int b) {
   return a + b;
}

// calling the add() method and storing the result in a variable
int result = add(3, 4);
System.out.println(result); // prints 7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code creates a method named add() that accepts two int parameters named a and b and returns their sum using the return keyword. The method is then called with the parameters 3 and 4 using its name and parentheses, and the result is stored in a variable named result. The value of result is then printed to the console, which should be 7. Methods that return values are useful when you want to perform a calculation or operation and pass the result back to the caller for further processing.&lt;/p&gt;

&lt;p&gt;In this case the syntax of the method is “public static int” because the methods returns a int value. If we want to return a String we have to declare it in the header of the method (switch “int” to “String”).&lt;/p&gt;

&lt;h2&gt;
  
  
  Recursion
&lt;/h2&gt;

&lt;p&gt;Recursion is a powerful technique in programming that involves a function calling itself repeatedly until a certain condition is met.&lt;/p&gt;

&lt;p&gt;In Java, recursion is used to solve problems that can be broken down into smaller subproblems that are identical in nature. Recursive functions typically have a base case that defines the condition for stopping the recursion, and a recursive case that defines how the function calls itself with smaller subproblems. Here is an example of how to use recursion in Java:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public static int factorial(int n) {
   if (n == 0) {
      return 1;
   } else {
      return n * factorial(n - 1);
   }
}

// calling the factorial() method with a parameter
int result = factorial(5);
System.out.println(result); // prints 120

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code creates a method named factorial() that uses recursion to calculate the factorial of a given number.&lt;/p&gt;

&lt;p&gt;The method accepts an int parameter named n and has a base case that returns 1 if n is 0, and a recursive case that multiplies n by the result of factorial(n - 1).&lt;/p&gt;

&lt;p&gt;The method is then called with the parameter 5 using its name and parentheses, and the result is stored in a variable named result.&lt;/p&gt;

&lt;p&gt;The value of result is then printed to the console, which should be 120.&lt;/p&gt;

&lt;p&gt;Recursive functions can be a powerful tool for solving complex problems that can be broken down into smaller, identical subproblems.&lt;/p&gt;

&lt;h2&gt;
  
  
  Classes and Objects
&lt;/h2&gt;

&lt;p&gt;Java is an object-oriented programming language, which means that it organizes code into classes and objects.&lt;/p&gt;

&lt;p&gt;Here are some key concepts related to classes and objects:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Class: a blueprint or template for creating objects&lt;/li&gt;
&lt;li&gt;Attributes: The variables of a Object&lt;/li&gt;
&lt;li&gt;Object: an instance of a class&lt;/li&gt;
&lt;li&gt;Constructor: a special method that is used to create new objects&lt;/li&gt;
&lt;li&gt;Method: a block of code that performs a specific task and can be called by an object of a class&lt;/li&gt;
&lt;li&gt;Inheritance: a mechanism that allows one class to inherit the properties and methods of another class&lt;/li&gt;
&lt;li&gt;Polymorphism: a mechanism that allows objects of different classes to be treated as if they are of the same class&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is an example of how to use these concepts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Person {
   private String name;
   private int age;

   public Person(String name, int age) {
      this.name = name;
      this.age = age;
   }

   public void sayHello() {
      System.out.println("Hello, my name is " + name + " and I am " + age + " years old.");
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Student extends Person {
   private String major;

   public Student(String name, int age, String major) {
      super(name, age);
      this.major = major;
   }

   public void sayHello() {
      System.out.println("Hello, my name is " + name + " and I am a " + major + " major.");
   }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Person person = new Person("John", 30);
person.sayHello();

Student student = new Student("Jane", 20, "Computer Science");
student.sayHello();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In general, attributes are declared as private in Java classes to enforce encapsulation, which is the idea of hiding the internal workings of an object from the outside world. This helps to prevent unintended access or modification of an object’s attributes by external code, which can cause bugs and security vulnerabilities. By encapsulating its attributes, a class can ensure that its behavior is predictable and consistent, making it easier to maintain and extend over time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Exception Handling
&lt;/h2&gt;

&lt;p&gt;Java provides a robust exception handling mechanism that allows you to gracefully handle errors that might occur during program execution. Here are some key concepts related to exception handling:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Exception: an event that occurs during program execution that disrupts the normal flow of code&lt;/li&gt;
&lt;li&gt;try/catch/finally blocks: used to catch and handle exceptions that might occur during program execution&lt;/li&gt;
&lt;li&gt;throw statement: used to explicitly throw an exception&lt;/li&gt;
&lt;li&gt;Checked and Unchecked Exceptions: Checked exceptions must be caught or declared in the method signature, while unchecked exceptions do not need to be caught or declared.
Here is an example of how to use these concepts:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;try {
   int[] numbers = {1, 2, 3};
   int x = numbers[3];
} catch (ArrayIndexOutOfBoundsException e) {
   System.out.println("An exception occurred: " + e.getMessage());
} finally {
   System.out.println("This code will always be executed.");
}

public void deposit(double amount) throws IllegalArgumentException {
   if (amount &amp;lt; 0) {
      throw new IllegalArgumentException("Amount cannot be negative.");
   }
   balance += amount;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Executing Code
&lt;/h2&gt;

&lt;p&gt;If you want to run the Java Programm without a IDE you have to open the terminal in your project root and run:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;javac [filename.java]&lt;br&gt;
java [filename]&lt;/code&gt;&lt;br&gt;
Note: Filename should be the same as the class name containing the main() method, with a .java extension.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this blog post, we’ve provided you with a full Java cheat sheet that covers some of the most commonly used features of the language. By using this cheat sheet, you’ll be able to write Java code more efficiently and with greater confidence. Whether you are a beginner or an experienced Java developer&lt;/p&gt;

&lt;p&gt;If you are interested in more Coding Tutorial you can check out our &lt;a href="https://forgetpasses.com/blog/category/coding"&gt;Coding Category&lt;/a&gt; or our &lt;a href="https://forgetpasses.com/blog"&gt;blog&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>webdev</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>NodeJs user authentication</title>
      <dc:creator>ForgetPasses</dc:creator>
      <pubDate>Tue, 24 Jan 2023 18:23:11 +0000</pubDate>
      <link>https://forem.com/forgetpasses/nodejs-user-authentication-1j89</link>
      <guid>https://forem.com/forgetpasses/nodejs-user-authentication-1j89</guid>
      <description>&lt;p&gt;Hey Guys,&lt;br&gt;
in this post I will show you how you can create a easy user authentication for your NodeJs application.&lt;/p&gt;

&lt;p&gt;First we need to install express,forgetpasses and body-parser&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; npm install forgetpasses
 npm install express
 npm install body-parser
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that we will create a new express app like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var express = require("express");
var app = express();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we want to configure the body-parser:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var bodyParser = require("body-parser");
app.use(bodyParser.urlencoded({
    extended: true
}))
app.use(bodyParser.json());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we succesfully created a express app with the body-parser. In order to implement the authentication system, we now want to configure the forgetpasses package.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const forgetpasses = require("forgetpasses");
var fp = new forgetpasses("YOUR_API_TOKEN")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can get your api token on &lt;a href="https://forgetpasses.com/dashboard/settings"&gt;https://forgetpasses.com/dashboard/settings&lt;/a&gt; after you created a service account on &lt;a href="https://forgetpasses.com/sign-up/client"&gt;https://forgetpasses.com/sign-up/client&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want to check the token you can call this function of the package:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data = await fp.checkToken(req);
console.log(data)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will log &lt;code&gt;true&lt;/code&gt; if your token is working and &lt;code&gt;false&lt;/code&gt; if its wrong.&lt;/p&gt;

&lt;p&gt;If you now want to let a user login you can do it this way:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.get("/generateLoginSession", async (req,res) =&amp;gt;{
    data = await 
    fp.generateLoginSession(req,res,"https://google.com")
    res.send(data)
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can now open this page and will see a lot of json send to your browser.&lt;br&gt;
You will now copy the &lt;code&gt;url&lt;/code&gt; and redirect your user to the url &lt;a href="https://forgetpasses.com/loginsession/URL"&gt;https://forgetpasses.com/loginsession/URL&lt;/a&gt;&lt;br&gt;
After a succesfull login your user will get redirected to the url you passes into the function. In our case its &lt;a href="https://google.com"&gt;https://google.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With this url the user now can login and you can check if a user is logged in with this way:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.get("/checkIfClientIsLoggedIn", async(req,res) =&amp;gt;{
    data = await fp.checkStatus(req);
    res.send(data);
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will log &lt;code&gt;true&lt;/code&gt; if your user is loggedin and &lt;code&gt;false&lt;/code&gt; if your user is not&lt;/p&gt;

&lt;p&gt;Thanks for reading. If you have question let me know&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>ForgetPasses</title>
      <dc:creator>ForgetPasses</dc:creator>
      <pubDate>Tue, 24 Jan 2023 13:36:11 +0000</pubDate>
      <link>https://forem.com/forgetpasses/forgetpasses-1dlg</link>
      <guid>https://forem.com/forgetpasses/forgetpasses-1dlg</guid>
      <description>&lt;p&gt;I am glad to introduce you my service "ForgetPasses".&lt;br&gt;
It is a passwordless authentication system for webdevelopers who do not want to code a ton of code just for a user authentication system.&lt;br&gt;
On one hand ForgetPasses open source package allows users to log in to their accounts without the need for a password, using a secure, alternative authentication method. Our package also includes robust user management capabilities for companies and developers.&lt;/p&gt;

&lt;p&gt;It is currently free to use and provides the following features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;User management with our website or the API&lt;/li&gt;
&lt;li&gt;Simple to implement for everybody&lt;/li&gt;
&lt;li&gt;Easy to use&lt;/li&gt;
&lt;li&gt;Fast and Secure&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Advantages of ForgetPasses are that it is easy to set up and you don't have to worry about user data. All user data is encrypted on our servers using the most secure encryption techniques. However, if you want to store them on your own servers as well, this is of course not a problem as you can easily set it up manually.&lt;/p&gt;

&lt;p&gt;So what do you think? Is it worth trying?&lt;br&gt;
&lt;a href="https://forgetpasses.com"&gt;https://forgetpasses.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>npm</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
