@malevich-studio/strapi-sdk-typescript 1.2.4 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -3
- package/dist/cli.cjs +5 -5
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +5 -5
- package/dist/cli.mjs.map +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -108,13 +108,41 @@ const articles = api.articles(
|
|
|
108
108
|
);
|
|
109
109
|
```
|
|
110
110
|
|
|
111
|
+
### Login Example
|
|
112
|
+
|
|
113
|
+
Next.js
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
'use server';
|
|
117
|
+
|
|
118
|
+
import Strapi from '@/strapi';
|
|
119
|
+
import { cookies } from 'next/headers';
|
|
120
|
+
|
|
121
|
+
export async function login(email: string, password: string) {
|
|
122
|
+
const strapi = new Strapi(process.env.STRAPI_URL || '');
|
|
123
|
+
const response = await strapi.login(email, password);
|
|
124
|
+
|
|
125
|
+
if (!response.error) {
|
|
126
|
+
(await cookies()).set('access_token', response.jwt, {
|
|
127
|
+
httpOnly: true,
|
|
128
|
+
secure: process.env.NODE_ENV === 'production',
|
|
129
|
+
sameSite: 'lax',
|
|
130
|
+
path: '/',
|
|
131
|
+
maxAge: 3600 * 24 * 365 * 10,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return response;
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
111
139
|
## 📌 TODO List
|
|
112
140
|
|
|
113
141
|
- [ ] Add authentication features:
|
|
114
|
-
- [
|
|
115
|
-
- [
|
|
142
|
+
- [x] Log In functionality
|
|
143
|
+
- [x] User Registration
|
|
116
144
|
- [ ] User privileges check
|
|
117
|
-
- [
|
|
145
|
+
- [x] Add localization features
|
|
118
146
|
- [ ] Refactor `src/generator/index.ts` for better maintainability
|
|
119
147
|
- [ ] Enable passing Strapi credentials via CLI parameters
|
|
120
148
|
- [ ] Allow customization of API class path
|
package/dist/cli.cjs
CHANGED
|
@@ -20126,7 +20126,7 @@ class Strapi {
|
|
|
20126
20126
|
return this.token;
|
|
20127
20127
|
}
|
|
20128
20128
|
async baseLogin(identifier, password) {
|
|
20129
|
-
const response = await this.fetchData('
|
|
20129
|
+
const response = await this.fetchData('auth/local', {
|
|
20130
20130
|
identifier,
|
|
20131
20131
|
password
|
|
20132
20132
|
}, {
|
|
@@ -20138,7 +20138,7 @@ class Strapi {
|
|
|
20138
20138
|
return response;
|
|
20139
20139
|
}
|
|
20140
20140
|
async baseRegister(data) {
|
|
20141
|
-
const response = await this.fetchData('
|
|
20141
|
+
const response = await this.fetchData('auth/local/register', data, {
|
|
20142
20142
|
method: 'POST',
|
|
20143
20143
|
});
|
|
20144
20144
|
if (!response.error) {
|
|
@@ -20147,7 +20147,7 @@ class Strapi {
|
|
|
20147
20147
|
return response;
|
|
20148
20148
|
}
|
|
20149
20149
|
async forgotPassword(email) {
|
|
20150
|
-
return await this.fetchData('
|
|
20150
|
+
return await this.fetchData('auth/forgot-password', { email }, {
|
|
20151
20151
|
method: 'POST',
|
|
20152
20152
|
});
|
|
20153
20153
|
}
|
|
@@ -20157,7 +20157,7 @@ class Strapi {
|
|
|
20157
20157
|
});
|
|
20158
20158
|
}
|
|
20159
20159
|
async baseResetPassword(password, code) {
|
|
20160
|
-
const response = await this.fetchData('
|
|
20160
|
+
const response = await this.fetchData('auth/reset-password', {
|
|
20161
20161
|
password,
|
|
20162
20162
|
passwordConfirmation: password,
|
|
20163
20163
|
code,
|
|
@@ -20170,7 +20170,7 @@ class Strapi {
|
|
|
20170
20170
|
return response;
|
|
20171
20171
|
}
|
|
20172
20172
|
async baseChangePassword(password, currentPassword) {
|
|
20173
|
-
const response = await this.fetchData('
|
|
20173
|
+
const response = await this.fetchData('auth/change-password', {
|
|
20174
20174
|
password,
|
|
20175
20175
|
passwordConfirmation: password,
|
|
20176
20176
|
currentPassword,
|