mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-19 14:05:23 +00:00
Commit from GitHub Actions (Generate Clients & Examples)
This commit is contained in:
@@ -53,6 +53,19 @@ func (t *UserService) ReadSession(request *ReadSessionRequest) (*ReadSessionResp
|
|||||||
return rsp, t.client.Call("user", "ReadSession", request, rsp)
|
return rsp, t.client.Call("user", "ReadSession", request, rsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset password with the code sent by the "SendPasswordResetEmail" endoint.
|
||||||
|
func (t *UserService) ResetPassword(request *ResetPasswordRequest) (*ResetPasswordResponse, error) {
|
||||||
|
rsp := &ResetPasswordResponse{}
|
||||||
|
return rsp, t.client.Call("user", "ResetPassword", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send an email with a verification code to reset password.
|
||||||
|
// Call "ResetPassword" endpoint once user provides the code.
|
||||||
|
func (t *UserService) SendPasswordResetEmail(request *SendPasswordResetEmailRequest) (*SendPasswordResetEmailResponse, error) {
|
||||||
|
rsp := &SendPasswordResetEmailResponse{}
|
||||||
|
return rsp, t.client.Call("user", "SendPasswordResetEmail", request, rsp)
|
||||||
|
}
|
||||||
|
|
||||||
// Send a verification email
|
// Send a verification email
|
||||||
// to the user being signed up. Email from will be from 'support@m3o.com',
|
// to the user being signed up. Email from will be from 'support@m3o.com',
|
||||||
// but you can provide the title and contents.
|
// but you can provide the title and contents.
|
||||||
@@ -170,6 +183,31 @@ type ReadSessionResponse struct {
|
|||||||
Session *Session `json:"session"`
|
Session *Session `json:"session"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ResetPasswordRequest struct {
|
||||||
|
// The code from the verification email
|
||||||
|
Code string `json:"code"`
|
||||||
|
// confirm new password
|
||||||
|
ConfirmPassword string `json:"confirmPassword"`
|
||||||
|
// the new password
|
||||||
|
NewPassword string `json:"newPassword"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ResetPasswordResponse struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type SendPasswordResetEmailRequest struct {
|
||||||
|
Email string `json:"email"`
|
||||||
|
// Display name of the sender for the email. Note: the email address will still be 'support@m3o.com'
|
||||||
|
FromName string `json:"fromName"`
|
||||||
|
Subject string `json:"subject"`
|
||||||
|
// Text content of the email. Don't forget to include the string '$code' which will be replaced by the real verification link
|
||||||
|
// HTML emails are not available currently.
|
||||||
|
TextContent string `json:"textContent"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SendPasswordResetEmailResponse struct {
|
||||||
|
}
|
||||||
|
|
||||||
type SendVerificationEmailRequest struct {
|
type SendVerificationEmailRequest struct {
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
FailureRedirectUrl string `json:"failureRedirectUrl"`
|
FailureRedirectUrl string `json:"failureRedirectUrl"`
|
||||||
|
|||||||
@@ -79,5 +79,5 @@
|
|||||||
"prepare": "npm run build"
|
"prepare": "npm run build"
|
||||||
},
|
},
|
||||||
"types": "index.d.ts",
|
"types": "index.d.ts",
|
||||||
"version": "1.0.741"
|
"version": "1.0.747"
|
||||||
}
|
}
|
||||||
@@ -12,9 +12,9 @@ func PublishAnEvent() {
|
|||||||
eventService := event.NewEventService(os.Getenv("MICRO_API_TOKEN"))
|
eventService := event.NewEventService(os.Getenv("MICRO_API_TOKEN"))
|
||||||
rsp, err := eventService.Publish(&event.PublishRequest{
|
rsp, err := eventService.Publish(&event.PublishRequest{
|
||||||
Message: map[string]interface{}{
|
Message: map[string]interface{}{
|
||||||
|
"type": "signup",
|
||||||
"user": "john",
|
"user": "john",
|
||||||
"id": "1",
|
"id": "1",
|
||||||
"type": "signup",
|
|
||||||
},
|
},
|
||||||
Topic: "user",
|
Topic: "user",
|
||||||
})
|
})
|
||||||
|
|||||||
9
examples/user/sendPasswordResetEmail/curl/sendPasswordResetEmail.sh
Executable file
9
examples/user/sendPasswordResetEmail/curl/sendPasswordResetEmail.sh
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
curl "http://localhost:8080/user/SendPasswordResetEmail" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "Authorization: Bearer $MICRO_API_TOKEN" \
|
||||||
|
-d '{
|
||||||
|
"email": "joe@example.com",
|
||||||
|
"fromName": "Awesome Dot Com",
|
||||||
|
"subject": "Password reset",
|
||||||
|
"textContent": "Hi there,\n click here to reset your password: myapp.com/reset/code?=$code"
|
||||||
|
}'
|
||||||
22
examples/user/sendPasswordResetEmail/go/sendPasswordResetEmail.go
Executable file
22
examples/user/sendPasswordResetEmail/go/sendPasswordResetEmail.go
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
package example
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/micro/services/clients/go/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Send an email with a verification code to reset password.
|
||||||
|
// Call "ResetPassword" endpoint once user provides the code.
|
||||||
|
func SendPasswordResetEmail() {
|
||||||
|
userService := user.NewUserService(os.Getenv("MICRO_API_TOKEN"))
|
||||||
|
rsp, err := userService.SendPasswordResetEmail(&user.SendPasswordResetEmailRequest{
|
||||||
|
Email: "joe@example.com",
|
||||||
|
FromName: "Awesome Dot Com",
|
||||||
|
Subject: "Password reset",
|
||||||
|
TextContent: `Hi there,
|
||||||
|
click here to reset your password: myapp.com/reset/code?=$code`,
|
||||||
|
})
|
||||||
|
fmt.Println(rsp, err)
|
||||||
|
}
|
||||||
17
examples/user/sendPasswordResetEmail/node/sendPasswordResetEmail.js
Executable file
17
examples/user/sendPasswordResetEmail/node/sendPasswordResetEmail.js
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
const { UserService } = require("m3o/user");
|
||||||
|
|
||||||
|
// Send an email with a verification code to reset password.
|
||||||
|
// Call "ResetPassword" endpoint once user provides the code.
|
||||||
|
async function sendPasswordResetEmail() {
|
||||||
|
let userService = new UserService(process.env.MICRO_API_TOKEN);
|
||||||
|
let rsp = await userService.sendPasswordResetEmail({
|
||||||
|
email: "joe@example.com",
|
||||||
|
fromName: "Awesome Dot Com",
|
||||||
|
subject: "Password reset",
|
||||||
|
textContent:
|
||||||
|
"Hi there,\n click here to reset your password: myapp.com/reset/code?=$code",
|
||||||
|
});
|
||||||
|
console.log(rsp);
|
||||||
|
}
|
||||||
|
|
||||||
|
sendPasswordResetEmail();
|
||||||
Reference in New Issue
Block a user