-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support send code with email. (#15)
- Loading branch information
Showing
24 changed files
with
492 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,45 @@ | ||
definitions: | ||
param.SendToParams: | ||
properties: | ||
email: | ||
type: string | ||
required: | ||
type: object | ||
response.Response: | ||
properties: | ||
code: | ||
type: integer | ||
data: {} | ||
msg: | ||
type: string | ||
type: object | ||
info: | ||
contact: {} | ||
paths: {} | ||
paths: | ||
/api/v1/email/code: | ||
post: | ||
description: Use email to send verification code | ||
parameters: | ||
- description: Email address | ||
in: body | ||
name: data | ||
required: true | ||
schema: | ||
$ref: '#/definitions/param.SendToParams' | ||
produces: | ||
- application/json | ||
responses: | ||
"200": | ||
description: Send success | ||
schema: | ||
allOf: | ||
- $ref: '#/definitions/response.Response' | ||
- properties: | ||
msg: | ||
type: string | ||
type: object | ||
summary: SendCode | ||
tags: | ||
swagger: "2.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Copyright © 2023 OpenIMSDK open source community. All rights reserved. | ||
// Licensed under the MIT License (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
|
||
package api |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright © 2023 OpenIMSDK open source community. All rights reserved. | ||
// Licensed under the MIT License (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
|
||
package api | ||
|
||
import ( | ||
"github.com/OpenIMSDK/OpenKF/server/internal/common" | ||
"github.com/OpenIMSDK/OpenKF/server/internal/common/response" | ||
"github.com/OpenIMSDK/OpenKF/server/internal/param" | ||
"github.com/OpenIMSDK/OpenKF/server/internal/service" | ||
"github.com/OpenIMSDK/OpenKF/server/pkg/log" | ||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
// SendCode | ||
// @Tags mail | ||
// @Summary SendCode | ||
// @Description Use email to send verification code | ||
// @Produce application/json | ||
// @Param data body param.SendToParams true "Email address" | ||
// @Success 200 {object} response.Response{msg=string} "Success" | ||
// @Router /api/v1/email/code [post] | ||
func SendCode(c *gin.Context) { | ||
var params param.SendToParams | ||
err := c.ShouldBindJSON(¶ms) | ||
if err != nil { | ||
response.FailWithCode(common.INVALID_PARAMS, c) | ||
return | ||
} | ||
|
||
svc := service.NewServiceWithGin(c) | ||
err = svc.SendCode(params.Email) | ||
if err != nil { | ||
log.Debug("SendCode error: ", err) | ||
response.FailWithCode(common.ERROR, c) | ||
return | ||
} | ||
|
||
response.Success(c) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.