✌
Introducción
Qué aprenderás sobre API con Sails.js
Presentando el proyecto
Comenzando con Sails
Introducción a Sails.js
Estructura de archivos
Preparación del ambiente de desarrollo
Setup de Espacio de Trabajo
Generando rutas REST con blueprint
Instalación de MongoDB
Conexión a Mongo
Instalar MySQL y usarlo con Sails (a través de WaterLine)
CRUD
Entendiendo operaciones CRUD
Crear modelo de rodada
Crear app de Ionic
Obtener todas las Rodadas: preparando la aplicación para mostrar datos
Obtener todas las Rodadas: mostrando los datos
Crear Rodada: recibiendo parámetros desde la URL
Crear Rodada: enviando información desde el formulario
Actualizar Rodada
Eliminar Rodadas
Autenticación y Usuarios
Obtener Rodada
Crear Modelo y Controller de Usuarios
Implementar validación de modelo
Nueva versión de la librería Joi
Crear Usuario
Cifrado de contraseña
Implementación de Login
Sistemas Externos
Uso de JSON Web Token
Policies: verificar si usuario está loggeado
Agregar usuario a Ride
Preparando la App para implementar el Login y Sign up
Implementando Login
Implementando Sign up
Agregar puntos de Rodada
Obtener API Keys para Clima y Distancias
Integración Google Geocoding: definiendo la lógica
Integración Google Geocoding: probando la funcionalidad
Integración Weather API
Desplegar clima, distancia y tiempo en cada punto de Rodada
Cierre
Cierre
You don't have access to this class
Keep learning! Join and start boosting your career
Imagine that you have worked hard to develop an application, and suddenly you realize that it is exposed to security vulnerabilities. Implementing a robust security layer is critical to protect both users and the data you handle. Let's explore how to configure this security layer so that all authentication and authorization execution works efficiently.
To start, you need to identify errors that arise when trying to access protected services without being authenticated. These steps will help you:
"Network" screen: When navigating in your application, use the browser's "Network" tab. Here you can view all network requests and their status. Look for any request that appears in red.
Console: Most browsers have a console that displays real-time execution errors. Look for messages related to missing authorization headers.
Pre-request token: Make sure you have a flow to request and send the token needed for authorization on requests to your backend.
To effectively implement login and registration, we must create a credential model that ensures that the data will be properly validated before being sent:
class Credential: email: str password: str confirmPassword: str = None # Optional, only for registration.
This model is a blueprint that ensures that the data required for authentication and registration are present and correct.
To interact with your backend and manage authentications, it is necessary to create services in your application that will handle login and registration requests:
Initial setup: define a new service called AuthenticationService
that will perform the authentication tasks.
Implementation in code:
login
and signUp
methods using the credential models as parameters.class AuthenticationService: def login(self, credential: Credential): # Implement login logic here
def signUp(self, credential: Credential): # Implement signup logic here
Designing a friendly user interface is as crucial as the backend logic. You must make sure that the screen is intuitive:
HTML form: Create a form in your HTML with input fields for email and password, and a submit button.
Link to credentials: Make sure that the data entered in the form is correctly linked to the attributes of your Credential
model.
Style and usability: Make sure the form is properly styled to have a clean and professional format.
<form> <ion-item> <ion-input [(ngModel)]="credential.email" placeholder="Email" type="email"></ion-input> </ion-item> <ion-item> <ion-input [(ngModel)]="credential.password" placeholder="Password" type="password"></ion-input> </ion-item> <ion-button (click)="login()">Login</ion-button></form></form>
Prepare a comparable form for registration using a similar methodology, but be sure to ask for password confirmation to improve security and user experience.
<form> <ion-item> <ion-input [(ngModel)]="credential.email" placeholder="Email" type="email"></ion-input> </ion-item> <ion-item><ion-item> <ion-input [(ngModel)]="credential.password" placeholder="Password" type="password"></ion-input> </ion-item> <ion-item> <ion-input [(ngModel)]="credential.confirmPassword" placeholder="Confirm Password" type="password"></ion-input> </ion-item> <ion-button (click)="signUp()">Signup</ion-button></form>
In summary, the correct implementation of security layers and services not only protects data integrity but also strengthens users' trust towards your application. If you follow these steps, you will be well on your way to ensuring that credentials are managed securely and efficiently. Go ahead and feel free to refine and expand your knowledge of security and web development!
Contributions 1
Questions 1
✌
Want to see more contributions, questions and answers from the community?