Skip to content

Commit 3abe33f

Browse files
committed
update readme
1 parent 6f85560 commit 3abe33f

File tree

1 file changed

+3
-122
lines changed

1 file changed

+3
-122
lines changed

README.md

Lines changed: 3 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -42,132 +42,13 @@ import {FusioSdkModule, FusioService as Sdk} from "ngx-fusio-sdk";
4242
//...
4343
imports: [
4444
//...
45-
FusioSdkModule
45+
FusioSdkModule.forRoot({
46+
baseUrl: 'https://myapi.fusio.cloud',
47+
})
4648
],
4749
providers: [
4850
{provide: Sdk, useExisting: FusioService}
4951
],
5052
//...
5153
})
5254
```
53-
54-
## Login
55-
56-
This component shows how you can build a [login controller](https://github.com/apioo/fusio-apps-developer/blob/master/src/app/login/login.component.ts).
57-
58-
```typescript
59-
import {Component, OnInit} from '@angular/core';
60-
import {Message} from "fusio-sdk/dist/src/generated/consumer/Message";
61-
import axios from "axios";
62-
import {UserService} from "ngx-fusio-sdk";
63-
import {Router} from "@angular/router";
64-
import {User_Account} from "fusio-sdk/dist/src/generated/consumer/User_Account";
65-
import {FusioService} from "../fusio.service";
66-
67-
@Component({
68-
selector: 'app-login',
69-
templateUrl: './login.component.html',
70-
styleUrls: ['./login.component.css']
71-
})
72-
export class LoginComponent implements OnInit {
73-
74-
credentials: Credentials = {
75-
username: '',
76-
password: ''
77-
}
78-
79-
constructor(private fusio: FusioService, private user: UserService<User_Account>, private router: Router) {
80-
}
81-
82-
async login() {
83-
try {
84-
const client = this.fusio.getClientWithCredentials(this.credentials.username, this.credentials.password);
85-
const account = await client.consumerUser();
86-
const response = await account.getConsumerAccount().consumerActionUserGet();
87-
88-
this.user.login(response.data);
89-
90-
this.router.navigate(['/account']).then(() => {
91-
location.reload();
92-
});
93-
} catch (error) {
94-
if (axios.isAxiosError(error) && error.response) {
95-
this.response = {
96-
success: false,
97-
message: error.response.data.error_description || 'An unknown error occurred',
98-
};
99-
} else {
100-
this.response = {
101-
success: false,
102-
message: String(error),
103-
};
104-
}
105-
}
106-
}
107-
108-
}
109-
110-
interface Credentials {
111-
username: string,
112-
password: string
113-
}
114-
```
115-
116-
## Register
117-
118-
This component shows how you can build a [register controller](https://github.com/apioo/fusio-apps-developer/blob/master/src/app/register/register.component.ts).
119-
120-
```typescript
121-
import {Component, OnInit} from '@angular/core';
122-
import {Message} from "fusio-sdk/dist/src/generated/consumer/Message";
123-
import axios from "axios";
124-
import {User_Register} from "fusio-sdk/dist/src/generated/consumer/User_Register";
125-
import {FusioService} from "../fusio.service";
126-
127-
@Component({
128-
selector: 'app-register',
129-
templateUrl: './register.component.html',
130-
styleUrls: ['./register.component.css']
131-
})
132-
export class RegisterComponent implements OnInit {
133-
134-
credentials: User_Register = {
135-
name: '',
136-
email: '',
137-
password: '',
138-
}
139-
140-
passwordConfirm?: string;
141-
response?: Message;
142-
143-
constructor(private fusio: FusioService) {
144-
}
145-
146-
async register() {
147-
try {
148-
if (this.credentials.password !== this.passwordConfirm) {
149-
throw new Error('The provided password does not match with the confirmation password');
150-
}
151-
152-
const client = this.fusio.getClientAnonymous();
153-
const account = await client.consumerUser();
154-
const response = await account.getConsumerRegister().consumerActionUserRegister(this.credentials);
155-
156-
this.response = response.data;
157-
} catch (error) {
158-
if (axios.isAxiosError(error) && error.response) {
159-
this.response = {
160-
success: false,
161-
message: error.response.data.message || 'An unknown error occurred',
162-
};
163-
} else {
164-
this.response = {
165-
success: false,
166-
message: String(error),
167-
};
168-
}
169-
}
170-
}
171-
172-
}
173-
```

0 commit comments

Comments
 (0)