-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Success notification for credential validation
- Loading branch information
Showing
6 changed files
with
85 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package internal | ||
|
||
import ( | ||
"bytes" | ||
"io" | ||
"os" | ||
"os/exec" | ||
|
||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
func handleSync(ctx *gin.Context) { | ||
sourceServer := ctx.PostForm("sourceServer") | ||
sourceAccount := ctx.PostForm("sourceAccount") | ||
sourcePassword := ctx.PostForm("sourcePassword") | ||
destinationServer := ctx.PostForm("destinationServer") | ||
destinationAccount := ctx.PostForm("destinationAccount") | ||
destinationPassword := ctx.PostForm("destinationPassword") | ||
|
||
sourceDetails := Credentials{ | ||
Server: sourceServer, | ||
Account: sourceAccount, | ||
Password: sourcePassword, | ||
} | ||
|
||
destinationDetails := Credentials{ | ||
Server: destinationServer, | ||
Account: destinationAccount, | ||
Password: destinationPassword, | ||
} | ||
|
||
log.Infof("Syncing %s to %s", sourceDetails.Account, destinationDetails.Account) | ||
|
||
err := syncIMAP(sourceDetails, destinationDetails) | ||
if err != nil { | ||
ctx.HTML(200, "error.html", err.Error()) | ||
return | ||
} | ||
ctx.HTML(200, "success.html", "Synced "+sourceDetails.Account+" to "+destinationDetails.Account) | ||
} | ||
|
||
func syncIMAP(sourceDetails Credentials, destinationDetails Credentials) error { | ||
cmd := exec.Command("imapsync", "--host1", sourceDetails.Server, "--user1", sourceDetails.Account, "--password1", sourceDetails.Password, "--host2", destinationDetails.Server, "--user2", destinationDetails.Account, "--password2", destinationDetails.Password) | ||
var stdBuffer bytes.Buffer | ||
mw := io.MultiWriter(os.Stdout, &stdBuffer) | ||
|
||
cmd.Stdout = mw | ||
cmd.Stderr = mw | ||
|
||
if err := cmd.Run(); err != nil { | ||
return err | ||
} | ||
|
||
// Command output realtime | ||
// log.Println(stdBuffer.String()) | ||
|
||
return nil | ||
} |
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
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,20 @@ | ||
<div class="alert alert-success max-w-sm absolute top-0 right-0 mt-4 mr-4 cursor-pointer" id="error-notification"> | ||
<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||
<path fill-rule="evenodd" clip-rule="evenodd" | ||
d="M24 4C12.96 4 4 12.96 4 24C4 35.04 12.96 44 24 44C35.04 44 44 35.04 44 24C44 12.96 35.04 4 24 4ZM18.58 32.58L11.4 25.4C10.62 24.62 10.62 23.36 11.4 22.58C12.18 21.8 13.44 21.8 14.22 22.58L20 28.34L33.76 14.58C34.54 13.8 35.8 13.8 36.58 14.58C37.36 15.36 37.36 16.62 36.58 17.4L21.4 32.58C20.64 33.36 19.36 33.36 18.58 32.58Z" | ||
fill="#00BA34" /> | ||
</svg> | ||
|
||
<div class="flex w-full justify-between"> | ||
<div class="flex flex-col"> | ||
<span>Success</span> | ||
<span class="text-content2">{{if .Account}}Authentication successful for: | ||
{{.Account}}{{else}}{{.}}{{end}}</span> | ||
</div> | ||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||
<path fill-rule="evenodd" clip-rule="evenodd" | ||
d="M18.3007 5.71C17.9107 5.32 17.2807 5.32 16.8907 5.71L12.0007 10.59L7.1107 5.7C6.7207 5.31 6.0907 5.31 5.7007 5.7C5.3107 6.09 5.3107 6.72 5.7007 7.11L10.5907 12L5.7007 16.89C5.3107 17.28 5.3107 17.91 5.7007 18.3C6.0907 18.69 6.7207 18.69 7.1107 18.3L12.0007 13.41L16.8907 18.3C17.2807 18.69 17.9107 18.69 18.3007 18.3C18.6907 17.91 18.6907 17.28 18.3007 16.89L13.4107 12L18.3007 7.11C18.6807 6.73 18.6807 6.09 18.3007 5.71Z" | ||
fill="#969696" /> | ||
</svg> | ||
</div> | ||
</div> |